Thanks! I'll try it. So... what is detached for?
2009/6/26 Paul Reznicek <[email protected]>: > Juanjo Conti wrote: >> >> 2009/6/26 Juanjo Conti <[email protected]>: >>> >>> Hi, I wonder know if my nevow.athena.LiveElement intances are alive. >>> This means for example, the web browser was now closed. >>> >>> I've been checking the API documentation at >>> http://buildbot.divmod.org/apidocs/nevow.athena.LiveElement.html but >>> didn't fin any sutable method for asking this. >>> >> >> I thought I could use the LiveElement detached method >> http://buildbot.divmod.org/apidocs/nevow.athena._LiveMixin.html#detached >> but it semms not to be called when I close the browser where a >> LIveElement is living... > > Hello, > 2 months back I've had same question - working solution from Werner > is in attached message. > Regards, Paul > > > ---------- Mensaje reenviado ---------- > From: Werner Thie <[email protected]> > To: Twisted Web World <[email protected]> > Date: Wed, 22 Apr 2009 16:44:17 +0200 > Subject: Re: [Twisted-web] Athena LiveElement: how to putChild under unique > session URL? > Paul Reznicek wrote: >> >> [email protected] wrote: >>> >>> On 21 Apr, 08:57 pm, [email protected] wrote: >>>> >>>> Hello All, >>>> >>>> LiveElement is fantastic, but I'm too stupid to find out, >>>> how to put temporary page under sessiop URL... >>>> This work for js modules at start like: >>>> http://localhost:8080/user/<HASH clientID>/jsmodule/athena_test >>>> >>>> I'd like to add temporary during run time something like: >>>> http://localhost:8080/user/<HASH clientID>/your_data >>>> page or staticFile, which should exists only few minutes. >> >> Caveat is, that instances of gone clients are keeping in memory. Is there >> a way to find out, that a client is gone (closed browser or switched to >> other site)? > > Welcome to the land of garbage collecting languages... What was the losing > memory of the C++ ages is now the not releasing memory because of > noncollectable garbage and server processes eating all the memory the > machine has. I had to learn it the hard way but NEVER ever store a reference > to something like sessions, mind or the the hierarchy of your LiveElements > unless you're prepared to handle the breakup of the reference at cleanup > time. Also keep in mind that the object hierarchy of client and server must > be in sync or you're risking that the detach functionality does not work as > advertised. Please see the detach/detached functionality in athena.py > > class thePage(athena.LivePage): > > def beforeRender(self, ctx): > : > d = self.notifyOnDisconnect() > d.addErrback(self.disconn) > > def disconn(self, reason): > """ > we will be called back when the client disconnects, just iterate > over all children and call a disconnected func if available > """ > for child in self.liveFragmentChildren: > if hasattr(child, 'disconnected'): > child.disconnected(reason); > > Werner > > _______________________________________________ > Twisted-web mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web > > > _______________________________________________ > Twisted-web mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web > > -- Juanjo Conti _______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
