[Zope-dev] more on sessions in general.

Stuart 'Zen' Bishop zen@cs.rmit.edu.au
Fri, 19 Nov 1999 09:04:24 +1100 (EST)


On Thu, 18 Nov 1999, Anthony Baxter wrote:

> It seems to me that the Session type object as used in SQLSession is
> a useful general class of object (regardless of the backend storage).

There is a need for someone to write ZSession or DumbSession that simply
stores the information in a in-memory dictionary (or var/session for ZEO
compatibility?), which would then define the API.

> Is it worth making this a more general piece of Zope? Right now, you
> have to do a <dtml-call Session> at the start of the transaction to 
> get the REQUEST.SESSION object created - it would be nice if this was
> done automagically (and done in a way that allowed you to slot in a
> different Session object if you wanted it...)

How would you 'slot in' a session?

Perhaps it just calls getSession(this(),REQUEST), which would be aquired 
from higher-on-up. This method could defined in SQLSessionFolder, or just 
a DTML/external method the site manager left in the root folder, or we could 
patch OFS/Folder.py to give it a 'Session' property defining the class of the 
session object we use). The getSession method would return the existing 
session, if it exists, or returns a fresh one. Your code would then just
look like:

    <dtml-let session=getSession>
	blah
    </dtml-let>

It would be nice if REQUEST.SESSION was filled in for you if the session
class has been defined, but someone else will need to comment on its
feasibility :-)

-- 
 ___
   //     Zen (alias Stuart Bishop)     Work: zen@cs.rmit.edu.au
  // E N  Senior Systems Alchemist      Play: zen@shangri-la.dropbear.id.au
 //__     Computer Science, RMIT 	 WWW: http://www.cs.rmit.edu.au/~zen