Skip to content

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

Closed

Description

@sqlalchemy-bot

Migrated issue, originally created by Anonymous

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)
    # 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)
    # 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)
    # 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


Attachments: include_fix_r240.diff

Activity

  1. sqlalchemy-bot commented on Mar 26, 2007

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    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. sqlalchemy-bot commented on Mar 26, 2007

    @sqlalchemy-bot
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions