diff --git a/Products/zms/__init__.py b/Products/zms/__init__.py index 26bde8661..386ca3718 100644 --- a/Products/zms/__init__.py +++ b/Products/zms/__init__.py @@ -126,6 +126,7 @@ def registerDirectory(_context, name, directory=None, recursive=False, def initialize(context): """Initialize the product.""" + create_session_storage_if_neccessary(context) try: """Try to register the product.""" @@ -338,3 +339,25 @@ def translate_path(s): if s.startswith('/++resource++zms_/'): l = ['plugins', 'www']+s.split('/')[2:] return os.sep.join([ZMS_HOME]+l) + +def create_session_storage_if_neccessary(context): + """ + Ensure containers for temporary data. + """ + from OFS.Folder import Folder + from Products.Transience.Transience import TransientObjectContainer + + app = context.getApplication() + if not 'temp_folder' in app: + # Adding a 'folder' is a just fallback + # if a 'mount_point' is not available + # like usually configured via zope.conf + temp_folder = Folder('temp_folder') + app._setObject('temp_folder', temp_folder) + if not 'session_data' in app.temp_folder: + container = TransientObjectContainer( + 'session_data', + title='Session Data Container', + timeout_mins=20 + ) + app.temp_folder._setObject('session_data', container) diff --git a/Products/zms/standard.py b/Products/zms/standard.py index 81f8f5bf6..026e301d0 100644 --- a/Products/zms/standard.py +++ b/Products/zms/standard.py @@ -827,36 +827,8 @@ def get_session(context): """ Get http-session. """ - request = getattr( context, 'REQUEST', None) - if request.get('SESSION', None) == None: - create_session_storage_if_neccessary(context) - session = request.get('SESSION',request.environ.get('beaker.session',None)) - return session - -security.declarePublic('create_session_storage_if_neccessary') -def create_session_storage_if_neccessary(context): - """ - Ensure containers for temporary data. - """ - from OFS.Folder import Folder - from Products.Transience.Transience import TransientObjectContainer - - root = context.getPhysicalRoot() - if not 'temp_folder' in root: - # Adding a 'folder' is a just fallback - # if a 'mount_point' is not available - # like usually configured via zope.conf - temp_folder = Folder('temp_folder') - root._setObject('temp_folder', temp_folder) - # writeLog( context, 'Missing temp_folder added') - if not 'session_data' in root.temp_folder: - container = TransientObjectContainer( - 'session_data', - title='Session Data Container', - timeout_mins=20 - ) - root.temp_folder._setObject('session_data', container) - # writeLog( context, 'Missing session_data-container added') + request = context.REQUEST + return request.get('SESSION',request.environ.get('beaker.session',None)) security.declarePublic('get_session_value') def get_session_value(context, key, defaultValue=None):