[Twisted-web] problem with livepage-completion-notification-3 branche

Donovan Preston dp at ulaluma.com
Tue Jun 7 11:22:28 MDT 2005

On Jun 6, 2005, at 7:52 PM, Siegmund Fuehringer wrote:

> hi!
> livepage doesn't work, when i return a LivePage instance from
> a childFactory.
> eg:
> class Test( livepage.LivePage ):
> ...
> class Root( rend.Page ):
>     def childFactory( self, ctx, name ):
>     return Test( )   <---- doesn't work
>     child_muh = Test( )  <---- works
> it works in nevow trunk though.

Yes. This is correct. This gives the developer the correct amount of  
control over the lifetime of all ClientHandle instances associated  
with a LivePage.

If you want to build your LivePage in a childFactory method, just  
build it and cache it somewhere (self, for example) that will live  
for the appropriate lifetime for your application (which may be the  
entire lifetime of the application). Then, return the same instance  
out of this cache the next time it is requested. In this way, all  
LivePage requests go through the same LivePage instance, and thus  
through the same clientHandleFactory, and thus the correct  
ClientHandle instances can be located.

This allows you to do things like have one LivePage per person, using  
guard, or share the same LivePage between everybody, by always  
returning the same instance for the same URL.


More information about the Twisted-web mailing list