[Zope] Persistant session.

Chris McDonough chrism@zope.com
11 Apr 2003 11:41:40 -0400


The 'add' script is only called the first time a session object is
created, and at this point there is no data in the session data object.
It doesn't get called every time an item is added to session data.
 
To service your use case, I'd try hook the 'delete' script to obtain
session values from when the session is about to expire (at which point
there will be data in the session data object).  The next time they come
back, you should be able to use a script at login to attempt to pull
their data out of persistent storage.

- C


On Fri, 2003-04-11 at 11:02, Brenton Bills wrote:
> Greetings guys,
> 
> We have a small demo site that we would like to record who vists and
> if they come back give a little message saying we know who they are
> and we welcome them back. To do this I am using Session. The thing is
> we want the data to be persistant so we are attempting to write the
> data out to a db.
> 
> So we set the add/del to be two python scripts.
> 
> our add one is something like this,
> 
> args==item,container.
> <start>
> ZopeID = container.browser_id_manager.getBrowserId()
> 
> records = container.sqlLstSession(zsession_key=ZopeID)
> 
> if len(records) == 0:
>     # Database hold no session row for this session
>     # Create a new row for this session
>     container.sqlInsSession(zsession_key=ZopeID)
> 
> # Regardless of wether we just created the session row, or one existed already, update it with item
> container.sqlUpdSessionData(zsession_key=ZopeID, zsession_value=item)
> 
> </end>
> 
> Except when we call REQUEST.SESSION.set('test_item','test_value'), the data in the
> contents of the SESSION data structure contains no data, eg.
> 
> demo=# select * from zsession_data;
>     zsession_key     |                           zsession_value
> ---------------------+--------------------------------------------------------------------
>  76055663A0wuh14y-MQ | id: 10500762450365664153, token: 76055663A0wuh14y-MQ, contents: []
> (1 row)
> 
> Have we done something wrong in where we presume the update gets called? How do we
> get just the contents of the item?
> 
> Regards,
> Brenton Bills.
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )