sqlalchemy / sqlalchemy/mako

Template.imports can break cache reload.

Open
#237 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug compiler
Dominant language
Python
Stars
459
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Migrated issue, originally created by Cody Taylor (@CodeMan99)

When moving an importable name out of a template context and add it to the imports instead the source template does not change, but the rendered module does.

This should be documented at very least.

The easiest solution I can think of is to render the imports argument as a fake template. If the fake template is invalidate, set a flag to invalidate all the template source files we are aware of, particularly in the TemplateLookup case.

Potentially, we could actually import the imports and add that to the context, but that is also a work-around that would need documented. Though users shouldn't attempt to provide a context name that they are already importing anyway.

(willing to work on this provided buy-in on any of the proposals)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the cache-reload behavior when an importable name moves into Template.imports without changing the source template. Inspect the Template.imports and TemplateLookup paths, then review the discussion's proposed fake-template and context-import approaches. Done requires an agreed fix or documented behavior for rendered-module invalidation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.