[Twisted-Python] Woven page instances deferring to each other...

Mary Gardiner mary-twisted at puzzling.org
Wed Oct 8 02:02:12 EDT 2003

On Wed, Oct 08, 2003, Mary Gardiner wrote:
> Assuming you meant "I'd like totally different HTML generated if
> there is an error state" you probably do want macros or something like
> them. The best documentation I've seen on this is here:
> http://twistedmatrix.com/pipermail/twisted-python/2003-June/004662.html


A nicer solution may be to have the parent Page (by this I mean
http://example.com/bob/ is a parent and http://example.com/bob/result/
is a child -- parents in the URL structure) do the check and return an
object of a different Page class, something like:

class MyParentPage(page.Page):

    def getDynamicChild(self, name, request):

        if error_condition_1:
            return ErrorPage1()
        elif error_condition_2:
            return ErrorPage2()
            return NormalChildPage()

If there's any way you can determine if the error has happened before
the child page starts rendering, then I suspect it would be nicer to do
the error check at child creation time, rather than when the child

You can then use macros for something like their normal function: which
is defining the bits of pages that look mostly the same across lots of
pages (navigation bars and the like).


More information about the Twisted-Python mailing list