[Twisted-web] fragments with child lookup

Markus Schiltknecht markus at bluegap.ch
Thu Sep 21 11:08:16 CDT 2006


I would like to use the child lookup mechanism (locateChild or 
childFactory) but then again, I want Fragments. I'm sure there is a 
proper way to do what I want. Let my try to explain with a URL mapping 
to templates mapping:

/           ->     common.xml
/foo        ->     common.xml / foo.xml
/bar        ->     common.xml / bar.xml
/bar/baz    ->     common.xml / bar.xml / baz.xml

common.xml as well as bar.xml both have a 'sub-content' renderer, which 
calls the next template. Of course this all happens dynamically.

I've tried two things:

a) make locateChild always return self, () and save which child it 
contains (and which it has to return as it's 'sub-content'. 
Unfortunately that stops the children lookup and I would have to invoke 
it locateChild of the child with segments[1:] myself. That seems ugly.

b) make locateChild return the real Child. That seems the right thing to 
do. But then I only get the latest child's template (i.e. baz.xml when 
calling the URL '/bar/baz' in the example above). How do I make that 
latest child render it's parents first?



More information about the Twisted-web mailing list