Related Entries

Interview with Ploners
Formulator makes life easy
Server side python
Getting undo history
Plone roles on

« Unison - file and directory synchroniser
» Mozilla Firebird 0.6

Resetting Zope's session timeout

A hacked python script to reset Zope's transient object persistence timeout.

Zope’s transient object session timeout defaults to 20 minutes. To set the timeout, go to /temp_folder/session_data and change the timeout there. When the timeout is changed, all objects in the session are cleared - so better not do this while people are on-line.

Unfortunately, this value gets reset to 20 minutes, every time Zope is restarted. My Zope servers are restarted every morning at 6:30am. I hacked in a reset script that is called at 7:10am every day. This script sets the timeout to 3 hours. It can be called using XML-RPC or through simple wget.

## Script (Python) "reset_session_timeout"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=set_timeout_to=180
##title=Set the timeout in default session manager to specified value
##
"""
Please go to this script like http://whatever_server/reset_session_timeout
after every restart of the server
"""
sess = container.temp_folder.session_data
curr = sess.getTimeoutMinutes()
set_timeout_to=int(set_timeout_to)
if curr != set_timeout_to:
    sess.setTimeoutMinutes(set_timeout_to)
return sess.getTimeoutMinutes()

Give this proxies of Owner and Manager - both these are not necessary, but this is the easy way out :-)

  1. I believe there's an environment variable you can set in the 'start' script to set the timeout.

    Check out 'doc/ENVIRON.txt'.

    Nicely - in Zope 2.7, all those environment variables are going away and Zope will be configurable via an Apache-like config file.

    Posted by: Jeffrey Shell on May 16, 2003 11:00 AM
  2. Jeff is right, there is an env variable for this. For the sake of understanding - and should you ever need to have greater control over what shows up in the temp_folder on startup, you can see/change the code in /lib/python/OFS/Application.py

    Posted by: Edward Pollard on May 28, 2003 11:41 AM
  3. for an overview of sessions
    see:

    http://usergram.com/iis/session/

    Posted by: session on September 20, 2003 02:47 AM
  4. We can set session variables Nicely in Zope2.7.
    you can find zope.conf file in your Zope2.7 instance home,located in path INSTANCE_HOME/etc/zope.conf.
    In zope.conf they documented very good, every one can understand and set.

    Posted by: Murthy on May 4, 2004 08:19 PM
  5. Hello Babu - Funny that I found this page on google, I guess I should have looked here in the first place! :-)

    Since my company has no plans to move to 2.7 anytime soon we are stuck with version 2.5. I have looked at the application.py script and was wondering if I could get a little more info on what to change.

    Would I just have to change this line?
    timeout_spec = env_has('ZSESSION_TIMEOUT_MINS', '')

    Any direction would be greatly appreciated..

    Posted by: John Zack on September 2, 2004 10:24 PM
  6. Let me answer my own question, all I had to do was goto /lib/python/OFS/Application.py and change:
    timeout_spec = env_has('ZSESSION_TIMEOUT_MINS', '')
    To:
    timeout_spec = env_has('ZSESSION_TIMEOUT_MINS', '45')

    Cheers!

    Posted by: John Zack on September 8, 2004 01:59 AM
//-->