[Twisted-web] issue with session and LivePage
Carl Shimer
carl at clingfire.net
Sun Jun 12 11:16:36 MDT 2005
Hi,
I have a guarded site using livepage. If the user is currently viewing a
livepage site and lets the session expire (i.e they do nothing), livepage
will generate a client side alert that is basically the contents of the
stylesheet in failure.py. Not such a good user experience :)
After some digging I noticed that Livepage doesn't have a notifyOnExpire
handler (liveevil does however). The solution is to add a handler in the
goingLive implementation:
def goingLive(self,ctx,handle):
self.handle = handle
inevow.ISession(ctx).notifyOnExpire(self.OnExpireCallBack)
The problem is in the implementation of OnExpireCallback. The current code:
def OnExpireCallBack(self):
# send the user back to the main page
self.handle.sendScript('window.location.href = "/"')
self.handle._closeComplete()
A couple of issues here:
1) it doesn't seem right to call _closeComplete() but it seems to work. Is
there a better solution?
2) I would like to do something a bit fancier here that involves displaying
a DIV for 1 sec and then redirecting to the main page. Sample client side
JS (you could do the same thing by using the client handle).
function handleLogout(strval)
{
newval = "<div id='logoutpopup'>" + strval + "</div>";
nevow_appendNode('maincontent',newval)
self.setTimeout("window.location.href = \"/\"",500) }
However, calling handleLogout before calling _closeComplete() will result in
the same error mentioned at the top. Perhaps a timing issue?
Perhaps some of these issues will be resolved with donovan's new livepage,
although I noticed on his branch that there still isn't a notifyOnExpire
handler.
Regards,
Carl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20050612/9e9054a9/attachment.htm
More information about the Twisted-web
mailing list