[Zope] Persistant session.
Brenton Bills
billsb@optushome.com.au
Sat, 12 Apr 2003 01:02:16 +1000
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.