[Twisted-web] Nevow: How to use sessions?

Andrea Arcangeli andrea at cpushare.com
Wed Dec 15 03:25:36 MST 2004

On Tue, Dec 14, 2004 at 08:01:06AM -0800, Donovan Preston wrote:
> compy.registerAdapter(UserManager, GuardSession, IUserManager)
> In this way, when you say IUserManager(ISession(ctx)) without having 
> previously called setComponent on the session with the IUserManager 
> interface, your UserManager adapter will be constructed and set on the 
> session for you automatically. Future calls to 
> IUserManager(ISession(ctx)) will return the same instance.
> Hope this helps,

It helped a lot thanks. I assume UserManager must inherit compy.Adapter
and IIUserManager must inherit compy.Interface.

I've some more question ;)

1) Is it possible to "unregister" and free the memory for the while
UserManager adapter istance? The way I understand it, after the istance
of UserManager is created, it gets linked by compy to the session
istance. Now I could delete all members from the "UserManager" istance
to release memory, but the UserManager would be still linked (and in
turn allocated in memory) until the session expires. Of course I assume
all istances associated to an instance via compy.registerAdapter(..,
GuardSession,... ) will be automatically garbage collected when the
session expires.

2) am I right I can vary the length of a session with something like

	nevow_resource = guard.SessionWrapper(portal_obj)
	nevow_resource.sessionLifetime = 300

3) what is the difference between compy.Interface and


More information about the Twisted-web mailing list