Description:
Sessions are great, and the default Zope configuration (keeping Sessions in a TemporaryFolder) works well as long as [1] you don't restart Zope and [2] a user's requests are always served from the same Zope instance.
If you have multiple Zope instances tied together with ZEO, or you just don't want to wipe out all your site's sessions when you restart Zope, you need persistent sessions. With the integration of Shane's DBTab into Zope 2.7, and the nifty new ZConfig, it's not that hard to set up.
The following assumes that you've used the standard (as of 2.7) 'configure/make/make install', 'bin/mkzopeinstance', and 'bin/mkzeoinstance' process to make an Instance Home.
o Add to the Instance Home's 'etc/zeo.conf' file these lines::
<filestorage main>
path $INSTANCE_HOME/var/Data.fs
</filestorage>
<filestorage session>
path $INSTANCE_HOME/var/Session.fs
</filestorage>
o Add to the Instance Home's 'etc/zope.conf' file these lines::
<zodb_db main>
<zeoclient>
server $INSTANCE/var/zeo.soc
storage main
name main
client main
var $INSTANCE/var/
</zeoclient>
mount-point /
</zodb_db>
<zodb_db session>
<zeoclient>
server $INSTANCE/var/zeo.soc
storage session
name session
client session
var $INSTANCE/var/
</zeoclient>
mount-point /session_folder
</zodb_db>
<zodb_db temporary>
<temporarystorage>
name temp
</temporarystorage>
mount-point /temp_folder
container-class Products.TemporaryFolder.TemporaryContainer
</zodb_db>
o Note: adjust the 'server' lines to fit your ZEO configuration. The example assumes that you are using a Unix socket in the same directory as the databases.
o Start ZEO and Zope using 'bin/zeoctl start' then 'bin/zopectl start'.
o Wait until 'log/event.log' exists and shows a successful startup.
o Open the ZMI in a browser. Add a ZODB Mount Point to the root, checking the boxes next to '/session_folder' and "Create new folders if..."
o Add a Transient Object Container named 'session_data' to '/session_folder'.
o Edit the Transient Object Container Path of '/session_data_manager' to '/session_folder/session_data'.
Explanation:
This configuration tells ZEO to create a 'Session.fs' FileStorage in addition to the typical root 'Data.fs', and mount it on top of the Folder '/session_folder'. Since we are overriding the default zodb_db setup, we also need to provide an explicit configuration for the TemporaryStorage that Zope normally mounts on '/temp_folder'.
Comments:
bloat? by slinkp - 2004-10-28
Cool idea, but does the Session.fs just keep growing?
Does the session data manager delete old crufty sessions?
If so, I assume that regular packing of Session.fs is a good idea?