[Twisted-web] Sessions with LivePage?
chris.were at gmail.com
Sun Jul 24 20:51:10 MDT 2005
> > I don't know of any reason why there would be an issue using sessions
> > with livepage. In fact, my "Secret Project" uses them. Just as an
> > experiment, you might want to try wrapping the root resource in a
> > nevow.guard.SessionWrapper so that you get guard's modern sessions, not
> > the old crufty twisted-web one.
That seemed to fix the problems - Now you've got me using guard I have
more questions ;)
How can I specify the URL to redirect to when a user logs in or logs
out? For example if i browse to /index and login, I want to be
redirected to /home. If I'm at /some-page and click logout I still
want to be at that page (not sent back to /index) - or sometimes i
will want to redirect on logout. I'm struggling to see how this is
possible at the moment.
On IRC it was suggested redirecting to the final url before logging
in, but that seems a little clumsy and just moving the problem (I also
don't know how to perform a login without using a form with
action=url.root.child(guard.LOGIN_AVATAR)). It also doesn't address
the issue of controlling the URI for logging out.
I'm working with a modified guarded.py example, but here is the portal
and Page() object I'm using (the createResource() is identical to
"""A simple implementor of cred's IRealm.
For web, this gives us the LoggedIn page.
def requestAvatar(self, avatarId, mind, *interfaces):
for iface in interfaces:
if iface is inevow.IResource:
# do web stuff
if avatarId is checkers.ANONYMOUS:
resc = Page(None)
resc.realm = self
return (inevow.IResource, resc, noLogout)
resc = Page(avatarId)
resc.realm = self
return (inevow.IResource, resc, resc.logout)
raise NotImplementedError("Can't support that interface.")
self.avatar = avatar
# child_xxx etc. etc.
## self.original is the page's main data -- the object that was
passed in to the constructor, and
## the object that is initially passed as the 'data' parameter to renderers
print "%s logged out!" % self.original
More information about the Twisted-web