Avoid naming conflict with 'modules' template parameter #322

Merged
merged 1 commit into from Aug 3, 2011

Conversation

Projects
None yet
2 participants
@alekstorm
Contributor

alekstorm commented Jul 29, 2011

Add extra _modules reference to modules list in template parameters, which is used by the {% module ... %} directive to avoid naming conflicts with Python modules named modules (yes, I ran into this).

Presumably, in a later version, the modules reference can be deprecated in favor of _modules?

Add extra '_modules' reference to modules list in template parameters…
…, which is used by {% module ... %} directive to avoid naming conflicts with Python modules named 'modules'
@bdarnell

This comment has been minimized.

Show comment Hide comment
@bdarnell

bdarnell Jul 30, 2011

Member

I think I'd rather keep "modules" as a semi-reserved word in the template namespace. Is there any reason you can't use "import modules as mods" or something like that?

Member

bdarnell commented Jul 30, 2011

I think I'd rather keep "modules" as a semi-reserved word in the template namespace. Is there any reason you can't use "import modules as mods" or something like that?

@alekstorm

This comment has been minimized.

Show comment Hide comment
@alekstorm

alekstorm Jul 30, 2011

Contributor

That is a workaround, but the normal Tornado convention for naming generated variables (which modules certainly is) seems to be prefixing with an underscore (_tmp and _buffer are two I can recall off the top of my head). I don't see any reason to keep modules lying around as a variable, since it always seemed like a bit of a hack - a problem Tornado 2.0 solved with the {%module ...%} directive.

Contributor

alekstorm commented Jul 30, 2011

That is a workaround, but the normal Tornado convention for naming generated variables (which modules certainly is) seems to be prefixing with an underscore (_tmp and _buffer are two I can recall off the top of my head). I don't see any reason to keep modules lying around as a variable, since it always seemed like a bit of a hack - a problem Tornado 2.0 solved with the {%module ...%} directive.

@alekstorm

This comment has been minimized.

Show comment Hide comment
@alekstorm

alekstorm Jul 31, 2011

Contributor

I just realized I may not have made clear that modules is kept as a reference - there's now simply an alias _modules, which is used by the {% module ... %} directive. No existing code will be broken.

Contributor

alekstorm commented Jul 31, 2011

I just realized I may not have made clear that modules is kept as a reference - there's now simply an alias _modules, which is used by the {% module ... %} directive. No existing code will be broken.

@bdarnell bdarnell merged commit a286935 into tornadoweb:master Aug 3, 2011

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