Skip to content
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

using caller inside of <%call> can be polluted #170

Closed
sqlalchemy-bot opened this issue Aug 5, 2011 · 3 comments
Closed

using caller inside of <%call> can be polluted #170

sqlalchemy-bot opened this issue Aug 5, 2011 · 3 comments

Comments

@sqlalchemy-bot
Copy link

@sqlalchemy-bot sqlalchemy-bot commented Aug 5, 2011

Migrated issue, originally created by Michael Bayer (@zzzeek)

moving the call to <%self:A> below the caller changes to an endless loop, removing the <%self:A> call altogether removes the issue. So <%self:A> is affecting the identity of caller and it appears to be a codegen issue.

from mako.template import Template

x = """
<%def name="A()">
A
${caller.body()}
</%def>

<%def name="B()">
B
${caller.body()}
</%def>

<%def name="C()">
 C
 <%self:B>
   <%self:A>
      A body
   </%self:A>
    B body
   ${caller.body()}
 </%self:B>
</%def>

<%self:C>
C body
</%self:C>
"""
t = Template(x)
print t.code
print t.render()
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 5, 2011

Michael Bayer (@zzzeek) wrote:

and here is the patch

diff -r 4f554cb3f613ed8910ea3524a0787b3b726ea6ae mako/codegen.py
--- a/mako/codegen.py	Fri Jul 08 10:09:03 2011 -0400
+++ b/mako/codegen.py	Fri Aug 05 17:33:21 2011 -0400
@@ -847,10 +847,10 @@
 
         self.printer.writelines(
             # get local reference to current caller, if any
-            "caller = context.caller_stack._get_caller()",
+            "__M_caller = context.caller_stack._get_caller()",
             # push on caller for nested call
             "context.caller_stack.nextcaller = "
-                "runtime.Namespace('caller', context, callables=ccall(caller))",
+                "runtime.Namespace('caller', context, callables=ccall(__M_caller))",
             "try:")
         self.write_source_comment(node)
         self.printer.writelines(
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 5, 2011

Michael Bayer (@zzzeek) wrote:

293531b

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Aug 5, 2011

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.