rendering sub-Pages in nevow (probable bug)
Hi *, I am using nevow 0.1 so if this has been fixed/is a know problem just redirect me to the right resource. Apparently it is possible to serve a Page instance from a render_XXX method if it is implemented as a rend.stan docFactory but not if it tries to load a template from disk (rend.htmlfile). i.e., the following code (add some imports, etc.) works: class Foo(rend.Page): docFactory = rend.htmlfile('foo.html') def render_content(self, context, data): return context.tag.clear()[Bar()] class Bar(rend.Page): docFactory = rend.stan(T.p["Some content"]) but if Bar is implemented as follows, a "maximum recursion depth exceeded" error is raised (the function that gets called a zillion times is renderer._strflatten): class Bar(rend.Page): docFactory = rend.htmlfile('bar.html') I am trying to fix this, but I still don't know very well what happens under the hood during the rendering process, so hints are very apreciated. :) thanks, federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org We are all dust, Saqi, so play the lute We are all wind, Saqi, so bring wine. -- Omar Khayam
On Mon, 2004-05-03 at 09:18, Federico Di Gregorio wrote:
Hi *,
I am using nevow 0.1 so if this has been fixed/is a know problem just redirect me to the right resource.
Apparently it is possible to serve a Page instance from a render_XXX method if it is implemented as a rend.stan docFactory but not if it tries to load a template from disk (rend.htmlfile). i.e., the following code (add some imports, etc.) works [...]
Nevow 0.1 is very _very_ outdated. I'd recommend using SVN trunk instead, and if you want stability, just don't update unless you encounter bugs (like now :) Being able to return pages from render_ methods is (should be) fully supported in SVN trunk. You can even go a step further and denote a specific part of the doc factory which should be used for this: class SomePage(rend.Page): docFactory = rend.htmlstr(''' <html><body> <h1>Header</h1> <div nevow:pattern="content">Content</div> </body></html> ''') If this object is rendered as a page, the header will show up. But if you return it from a render_ method, then only the div with the "content" pattern (and everything inside it) will be used. So you can create pages with all the necessary fluff around the edges, but avoid rendering the "skin" (headers, navbars, what have you) multiple times. -- Alex Levy WWW: http://mesozoic.geecs.org/ "Never let your sense of morals prevent you from doing what is right." -- Salvor Hardin, Isaac Asimov's _Foundation_
Lì lunedì, 2004/05/03 alle 15:15, -0400, Alex Levy ha scritto:
On Mon, 2004-05-03 at 09:18, Federico Di Gregorio wrote:
Hi *,
I am using nevow 0.1 so if this has been fixed/is a know problem just redirect me to the right resource.
Apparently it is possible to serve a Page instance from a render_XXX method if it is implemented as a rend.stan docFactory but not if it tries to load a template from disk (rend.htmlfile). i.e., the following code (add some imports, etc.) works [...]
Nevow 0.1 is very _very_ outdated. I'd recommend using SVN trunk instead, and if you want stability, just don't update unless you encounter bugs (like now :)
using trunk and branches/freeform-patterned (after irc session with fzZzy) right now.
Being able to return pages from render_ methods is (should be) fully supported in SVN trunk.
it is not; here are the problems: trunk: stan -> works as expected htmlfile -> infinite recursion xmlfile -> no error but does not render (template copied 'as is' to output) branch: stan -> works as expected htmlfile -> works as expected xmlfile -> no error but does not render (template copied 'as is' to output) i can check the other loader if needed. a test case is on the way.
You can even go a step further and denote a specific part of the doc factory which should be used for this:
class SomePage(rend.Page): docFactory = rend.htmlstr(''' <html><body> <h1>Header</h1> <div nevow:pattern="content">Content</div> </body></html> ''')
If this object is rendered as a page, the header will show up. But if you return it from a render_ method, then only the div with the "content" pattern (and everything inside it) will be used. So you can create pages with all the necessary fluff around the edges, but avoid rendering the "skin" (headers, navbars, what have you) multiple times.
I don't find this much usefull, sorry. what we really need in a real use-case (on your browser in 15 days and GPL'ed after that :) is sub-template rendering. luckily enough loaders.htmlfile is working. hope to see that in trunk (and maybe a working xmlfile too) soon. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org We are all dust, Saqi, so play the lute We are all wind, Saqi, so bring wine. -- Omar Khayam
Lì lunedì, 2004/05/03 alle 15:15, -0400, Alex Levy ha scritto:
On Mon, 2004-05-03 at 09:18, Federico Di Gregorio wrote:
Hi *,
I am using nevow 0.1 so if this has been fixed/is a know problem just redirect me to the right resource.
Apparently it is possible to serve a Page instance from a render_XXX method if it is implemented as a rend.stan docFactory but not if it tries to load a template from disk (rend.htmlfile). i.e., the following code (add some imports, etc.) works [...]
Hi *, the problem has been solved on irc and i report here because i hate to search, find something in a ML archive and then nothing. empty. void. :) it was a problem with data not being correctly set (i had a mismatched data_xxx/nevow:data="Xxx" function). the right behaviour would have been to raise an error, not enter infinite recursion. fzzzy or gm helped me a lot and will fix it, i think. in the meantime check your "data". :) federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org We are all dust, Saqi, so play the lute We are all wind, Saqi, so bring wine. -- Omar Khayam
On Tue, 2004-05-04 at 10:16, Federico Di Gregorio wrote:
Lì lunedì, 2004/05/03 alle 15:15, -0400, Alex Levy ha scritto:
On Mon, 2004-05-03 at 09:18, Federico Di Gregorio wrote:
Hi *,
I am using nevow 0.1 so if this has been fixed/is a know problem just redirect me to the right resource.
Apparently it is possible to serve a Page instance from a render_XXX method if it is implemented as a rend.stan docFactory but not if it tries to load a template from disk (rend.htmlfile). i.e., the following code (add some imports, etc.) works [...]
Hi *,
the problem has been solved on irc and i report here because i hate to search, find something in a ML archive and then nothing. empty. void. :)
it was a problem with data not being correctly set (i had a mismatched data_xxx/nevow:data="Xxx" function). the right behaviour would have been to raise an error, not enter infinite recursion. fzzzy or gm helped me a lot and will fix it, i think. in the meantime check your "data". :)
It was mg actually. I'm 100% natural ;-) I added a test to trunk for the missing data problem and marked it as skipped as it passes in the freeform-patterned branch. I later realised that the test does not test the mispelled nevow:data attribute problem. That problem occurs in trunk and the branch. I will add another test later. Cheers, Matt -- __ / \__ Matt Goodall, Pollenation Internet Ltd \__/ \ w: http://www.pollenation.net __/ \__/ e: matt@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.
participants (3)
-
Alex Levy
-
Federico Di Gregorio
-
Matt Goodall