[Twisted-web] appropriate way to use patternGenerator

Carl Shimer carl at clingfire.net
Sun May 8 16:31:45 MDT 2005


Hi,

I spent the last couple of hours trying to get the nevow LivePage stuff to
work.  The problem was on this line of my code:

Inevow.IQ(self.docFactory).patternGenerator('foo')

After a big of debugging (well, a lot of debugging) I figured out that the
problem was that my stan tree (self.docFactory) wasn't fully complete,
rather due to my setup it contained functions that weren't evaluated yet.
patternGenerator() would fail because foo wasn't defined yet - it would be
defined later (perhaps after the page was rendered?)

Anway, my work around was to do this:

Inevow.IQ(self.tagfragments()).patternGenerator('foo') where tagfragments()
returns a partial stan tree.

Questions:

1) my solution seems like a hack :)  is there a way I can run
patternGenerator on the fully evaluated tree?
2) The way I am doing code reuse is via inheritance.  The parent object
(derived from rend.Page) has all the code for common elements like the page
header, doctype, and the docFactory.  The docFactory embeds a number of
entry points which may later overridden by a derived class.  So the child
page always overrides the content() function to render the main body of the
page.  Is the appropriate mechanism?  I read somewhere about the Fragment
class but didn't quite understand it.

Thanks,
Carl




More information about the Twisted-web mailing list