Issues

Issue #29 resolved

<%include file="${i}"/> broken as of r228

guest
created an issue

We have the following template on PylonsHQ:

<%include file="/docs/${g.current_version}/install.html"/> <%def name="title()">${parent.title()} - Install</%def> <%def name="nav()">Install</%def> <%inherit file="/layout.html"/>

As of r228, the include is broken with the error:

I keep getting this wack error Module _layout_html:59 in render_body >> context.write(unicode(self.yui_grid())) Module mako.runtime:200 in <lambda> >> return lambda *args, kwargs:callable_(self.context, *args, kwargs) Module _layout_html:100 in render_yui_grid >> context.write(unicode(caller.body())) Module mako.runtime:91 in call_wno_caller >> return callable_(*args, kwargs) Module _layout_html:51 in body >> context.write(unicode(next.body())) Module mako.runtime:200 in <lambda> >> return lambda *args, kwargs:callable_(self.context, *args, kwargs) Module _install_index_html:26 in render_body >> runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri) NameError: global name 'g' is not defined

The .py generated for this file as of r228 is:

def render_body(context,pageargs): locals = dict(pageargs=pageargs) foo = context.get('foo', UNDEFINED)

  1. SOURCE LINE 1 runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

Whereas before it would do something along the lines of:

def render_body(context,pageargs): locals = dict(pageargs=pageargs) g = context.get('g', UNDEFINED)

  1. SOURCE LINE 1 runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

I've attached a test for this and a patch that fixes it. You probably have a better version of the patch -- what it generates now is:

def render_body(context,pageargs): locals = dict(pageargs=pageargs) foo = context.get('foo', UNDEFINED) g = context.get('g', UNDEFINED)

  1. SOURCE LINE 1 runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

I suspect the 'foo' PythonCode business is some test code you left around in the r228 commit

Comments (1)

  1. Mike Bayer repo owner

    patch is in [changeset:241]. [changeset:242] I added some stuff to filter out the "fake" function name "foo" (which is now the less likely "DUMMY"). that is needed at the moment because i am using straight AST to parse out the list of arguments and AST needs to see "oh, its a callable".

    0.1.5 is definitely due now will try to get it out today/tomorrow.

  2. Log in to comment