uploading to trunk!

On Apr 17, 10:23 am, Jonathan Lundell <jlund...@pobox.com> wrote:
> On Apr 16, 2010, at 6:47 PM, mdipierro wrote:
>
> > I am readying your question and my answer again and I said something
> > silly. You should be able to do what you originally proposed
>
> > {{extend request.layout}} although I'd probably do {{extend
> > reponse.layout}} instead. I tried and both work for me (unless the app
> > is bytecode compiled). If the app is bytecode compiled dynamical
> > extend and imports are not supported.
>
> That sounds like what I'm seeing. The failure (traceback below) happens 
> during the compile itself.
>
> The exception is raised during the eval in parse_template:
>
>     # check whether it extends a layout
>     while 1:
>         match = re_extend.search(text)
>         if not match:
>             break
>         t = os.path.join(path, eval(match.group('name'), context))
>         try:
>             fp = open(t, 'rb')
>
> Perhaps the eval should be in a try, to make the error reporting a little 
> more explicit? Otherwise it's a little confusing for code that works normally 
> to crash a compile.
>
>
>
> > Massimo
>
> > On Apr 16, 8:09 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
> >> On Apr 16, 2010, at 5:13 PM, mdipierro wrote:
>
> >>> Not quite.
>
> >>> {{extend name}} without quote is supported by name has to be a
> >>> variable containing the name of the template. This allows to have
> >>> templates determined dynamically based on user for example.
>
> >> So instead of {{extend request.layout}}, what?
>
> >> Can I do:
>
> >> {{layout = request.layout}}
> >> {{extend layout}}
>
> >> ?
>
> >> Note that {{extend request.layout}} works fine in normal operation. It 
> >> only breaks when I try to compile the app, because request isn't defined 
> >> for the eval().
>
> >>> On Apr 16, 5:24 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
> >>>> On Apr 16, 2010, at 2:11 PM, Jonathan Lundell wrote:
>
> >>>>> I have several questions regarding app compiles, but the first one is 
> >>>>> this:
>
> >>>>> Error traceback
> >>>>> 1.
> >>>>> 2.
> >>>>> 3.
> >>>>> 4.
> >>>>> 5.
> >>>>> 6.
> >>>>> 7.
> >>>>> 8.
> >>>>> 9.
> >>>>> 10.
> >>>>> 11.
> >>>>> 12.
> >>>>> 13.
> >>>>> 14.
> >>>>> 15.
> >>>>> 16.
> >>>>> 17.
> >>>>> 18.
> >>>>> 19.
> >>>>> Traceback (most recent call last):
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/restricted.py", 
> >>>>> line 173, in restricted
> >>>>>     exec ccode in environment
> >>>>>   File 
> >>>>> "/Users/jlundell/VTC/vpeps-web2py/web2py/applications/admin/controllers/default.py",
> >>>>>  line 1061, in <module>
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/globals.py", line 
> >>>>> 96, in <lambda>
> >>>>>     self._caller = lambda f: f()
> >>>>>   File 
> >>>>> "/Users/jlundell/VTC/vpeps-web2py/web2py/applications/admin/controllers/default.py",
> >>>>>  line 213, in compile_app
> >>>>>     c = app_compile(request.args[0], request)
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/admin.py", line 
> >>>>> 141, in app_compile
> >>>>>     compile_application(folder)
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/compileapp.py", 
> >>>>> line 520, in compile_application
> >>>>>     compile_views(folder)
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/compileapp.py", 
> >>>>> line 293, in compile_views
> >>>>>     data = parse_template(file, path)
> >>>>>   File "/Users/jlundell/VTC/vpeps-web2py/web2py/gluon/template.py", 
> >>>>> line 139, in parse_template
> >>>>>     t = os.path.join(path, eval(match.group('name'), context))
> >>>>>   File "<string>", line 1, in <module>
> >>>>> NameError: name 'request' is not defined
> >>>>> The match in question is presumably {{extend request.layout}}, right?
>
> >>>> OK, that's what I changed. Because I was experimenting with layouts, I 
> >>>> changed {{extend 'layout.html'}} to {{extend request.layout}}, which I 
> >>>> assumed would work because request appears to be defined in views. But 
> >>>> it's not defined in the context of the extend logic's eval().
>
> >>>> It seems like a reasonable thing to be able to do....
>
> >>>> --
> >>>> Subscription 
> >>>> settings:http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to