[Twisted-Python] domtemplate examples

Donovan Preston dp at twistedmatrix.com
Sat Sep 14 13:52:39 MDT 2002


Bruce,

Your code totally rocks, and I liked it so much I abstracted it to 
apply to all Widgets, automatically. Basically, here's how it works;

I added a new method to Widget, setUp(self, request, node, data), which 
gets called before generateDOM. The common case of overriding 
generateDOM, doing some setup work, and then calling Widget.generateDOM 
can now be implemented by overriding setUp. As an added bonus, the 
Model data that the widget is meant to be operating on is passed in to 
the fourth parameter, data.

Then, I changed the way Widgets are rendered so that if a Widget is 
operating on a subModel which happens to be a Deferred instance, both 
setUp and generateDOM will be deferred until after the Deferred 
instance fires. So, you can make a database call in Model.__init__, 
save the deferred in a subModel, apply a Widget to the subModel, and 
you don't have to do anything to have your Widget operate correctly. 
Attached is an example.

Thanks for the clarity and inspiration, bruce!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: deferredList.rpy
Type: application/applefile
Size: 470 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020914/f635b09a/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deferredList.rpy
Type: application/text
Size: 80 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020914/f635b09a/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deferredList.py
Type: application/applefile
Size: 469 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020914/f635b09a/attachment-0010.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deferredList.py
Type: application/text
Size: 1200 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020914/f635b09a/attachment-0011.bin>


More information about the Twisted-Python mailing list