New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caanot use 'dict' builtin in templates #84

Closed
sqlalchemy-bot opened this Issue May 30, 2008 · 2 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented May 30, 2008

Migrated issue, originally created by Anonymous

In r375 there has been added a patch to allow the use of Python builtin names as template variables. I use the 'dict' builtin in several templates to make a dictionary, but with this patch the compiled template begins with the lines:

from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
_magic_number = 2
...

def render_body(context,**pageargs):
context.caller_stack._push_frame()
try:
__M_locals = dict(pageargs=pageargs)
dict = context.get('dict', UNDEFINED)
...

(ellipsis omitting rest of code)

and, on render time, Python complains with an UnboundLocalError: "local variable 'dict' referenced before assignment" due to the use of dict in the _M_locals line (just before trying to pull from
the context).

Regards,

Raúl García

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jun 2, 2008

Michael Bayer (@zzzeek) wrote:

thanks for keeping on trunk, this is fixed in 4a63492.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Jun 2, 2008

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment