[Twisted-web] Athena LiveElement: how to putChild under unique session URL?

Werner Thie wthie at thiengineering.ch
Wed Apr 22 10:44:17 EDT 2009

Paul Reznicek wrote:
> glyph at divmod.com wrote:
>> On 21 Apr, 08:57 pm, maillists at ivsn.com 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()

   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'):


More information about the Twisted-web mailing list