[Twisted-web] Handling childs at Nevow

Colin Alston karnaugh at karnaugh.za.net
Sat Jul 25 07:10:49 EDT 2009


On Sat, Jul 25, 2009 at 1:05 PM, Colin Alston <karnaugh at karnaugh.za.net>wrote:

>
>
> 2009/7/25 Siegmund Führinger <lists at 0xx0.net>
>
>> On Sat, Jul 25, 2009 at 10:06 AM, Colin Alston<karnaugh at karnaugh.za.net>
>> wrote:
>> > On Sat, Jul 25, 2009 at 9:04 AM, Michał Pasternak <michal.dtz at gmail.com
>> >
>> > wrote:
>> >>
>> >> BTW, are there any URL dispatchers (like the one Django has) out there
>> for
>> >> Nevow?
>> >
>> > I really and truly hope not.
>>
>> why not? urls are very important and using child_XXX methods is
>> sometimes not very convinient.
>
>
> Convenience at the cost of maintainability is not worth it.
>

 FWIW, you can subclass your page objects to create more generic ways to
deal with REST like arguments, as well as child page dispatch.

This is what I do in Enamel:

http://open.thusa.co.za/enamel/browser/trunk/enamel/pages.py#L68
http://open.thusa.co.za/enamel/browser/trunk/enamel/pages.py#L47

Then you can mix the page object appropriately and do something like

class FooPage(rend.Page):
    # Whatever...

class MyPage(pages.Standard):
    childPages = {
        'Foo' : FooPage
    }

    arbitraryArguments = True

    def render_foo(self, c, d):
        return c.tag[
            "You passed ", self.arguments[0], "instead of 'Foo'"
        ]

HTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20090725/fae31e5a/attachment.htm 


More information about the Twisted-web mailing list