[Zope] Temporary Folder Content - Session Data

Chris McDonough chrism at zope.com
Fri Sep 26 13:22:51 EDT 2003


On Fri, 2003-09-26 at 12:42, Milos Prudek wrote:
> > Session data containers contain session data objects, each of which
> > should be unique for a particular browser (user).  It's true that each
> > developer will share the same session namespace for a given user, but
> > you don't need to limit yourself to storing string-valued key-value
> > pairs in the top-level namespace of the session data object.  For
> > example, instead of:
> > 
> > context.REQUEST.SESSION['avariable'] = 'avalue'
> > 
> > ... you can do something like this:
> > 
> > my_app_namespace = context.REQUEST.SESSION.get('my_app', {})
> > my_app_namespace['avaraible'] = 'avalue'
> > context.REQUEST.SESSION.set('my_app', my_app_namespace)
> 
> Is this the only way to have separate session objects in an application?

The result of this isn't two separate session objects.  'my_app' is just
a namespace.  There can be any number of namespaces in the same session
data object.  It's the 'recommended way', FWIW.

> I tried to place two Session Data Managers in one folder. I tolds the 
> first of them to  Place SESSION in REQUEST object as "ses1", and the 
> second one to place it as "ses2". Zope seems to use only the first one. 
> When I listed the REQUEST, it contained "ses1" and "SESSION" (inherited 
> from default Session Data Managers).

Having two session data managers in the same folder isn't really
supported.

> That made me think that I can at least place a new Session Data Managers 
> hierarchic subfolders and all of them will be visible. A drawing will 
> easier to understand:
> 
> folderA/
>    SDM1 (place session as "ses1")
>    folderB/
>      SDM2 (place session as "ses2")
>      folderC/
>        SDM3 (place session as "ses3")
> 
> Surprisingly, when I print REQUEST from folderC, there are only two 
> session objects visible: SESSION and ses3.
> 
> Why is this?

That's not what I see (Zope 2.7 head).  When I print the request, I get
SESSION, ses1, ses2, and ses3.  This should indeed work (although I'm
not sure you'd really want to do this, namespaces seem easier and
clearer).

- C


-- 
Chris McDonough <chrism at zope.com>
Zope Corporation




More information about the Zope mailing list