[Twisted-Python] Woven Model extreme pain
syver at inout.no
Mon Oct 6 04:07:25 EDT 2003
Bill Gribble <grib at billgribble.com> writes:
> On Fri, 2003-10-03 at 03:32, Syver Enstad wrote:
> > <span model="foo" view="Widget">
> > <span model="0" view="Text"></span>
> > </span>
> > should work because the Widget handles the deferred model and
> > postpones processing of child nodes until the deferred result is
> > ready.
> Could you elaborate on this a little? I want to do this too (defer
> rendering in Woven) and I use Widget subclasses everywhere. At what
> point is it OK to produce a Deferred?
As the return value from a wmfactory_method and as Donovan mentions
that implies also as the return value from getData but I haven't done
def wmfactory_myList(self, request):
deferred = defer.Deferred()
reactor.callLater(2, deferred.callback, [1, 2, 3])
<span model="myList" view="Widget">
<span model="0" view="Text"></span>
<span model="1" view="Text"></span>
<span model="2" view="Text"></span>
Or with a List widget
<span model="myList" view="List">
<span pattern="listItem" view="Text"></span>
> The only method I override in my Widget subclasses is setUp. In my
> top-level Page subclass I have a single wvfactory_ method for a special
> View I use, and a getDynamicChild to fetch children (in this case, all
> the children are dynamic).
Then I think you will be home free, because you don't override
> Are you suggesting that I return a Deferred instead of a View from the
> wvfactory_ method? Or that I return a Deferred from the getDynamicChild
> method? Or what?
None of the above, what I tried to explain was that Widget.generate
handles deferred models. I don't think there is any support for
deferred page's or views, just models. This means that if you need
deferreds you have to use a model for that. This makes sense because
you should not put data in your view classes, because then they are
not views anymore.
More information about the Twisted-Python