def setup_sdm(portal): """ Setup session data manager. """ tf_name = 'temp_folder' idmgr_name = 'browser_id_manager' toc_name = 'temp_transient_container' sdm_name = 'session_data_manager' from Products.Sessions.BrowserIdManager import BrowserIdManager from Products.Sessions.SessionDataManager import SessionDataManager from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder from Products.Transience.Transience import TransientObjectContainer import transaction bidmgr = BrowserIdManager(idmgr_name) tf = MountedTemporaryFolder(tf_name, title='Temporary Folder') toc = TransientObjectContainer( toc_name, title='Temporary Transient Object Container', timeout_mins=20, ) session_data_manager = SessionDataManager( id=sdm_name, path=tf_name + '/' + toc_name, title='Session Data Manager', requestName='TESTOFSESSION', ) portal._setObject(idmgr_name, bidmgr) portal._setObject(sdm_name, session_data_manager) portal._setObject(tf_name, tf) portal.temp_folder._setObject(toc_name, toc) transaction.commit()
def _populate(app): bidmgr = BrowserIdManager(idmgr_name) tf = MountedTemporaryFolder(tf_name, 'Temporary Folder') toc = TransientObjectContainer(toc_name, title='Temporary ' 'Transient Object Container', timeout_mins=1) session_data_manager=SessionDataManager(id=sdm_name, path='/'+tf_name+'/'+toc_name, title='Session Data Manager') try: app._delObject(idmgr_name) except AttributeError: pass try: app._delObject(tf_name) except AttributeError: pass try: app._delObject(sdm_name) except AttributeError: pass app._setObject(idmgr_name, bidmgr) app._setObject(sdm_name, session_data_manager) app._setObject(tf_name, tf) transaction.commit() app.temp_folder._setObject(toc_name, toc) transaction.commit()
def _populate(app): from OFS.DTMLMethod import DTMLMethod from Products.Sessions.BrowserIdManager import BrowserIdManager from Products.Sessions.SessionDataManager import SessionDataManager from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder from Products.Transience.Transience import TransientObjectContainer import transaction bidmgr = BrowserIdManager(idmgr_name) tf = MountedTemporaryFolder(tf_name, title="Temporary Folder") toc = TransientObjectContainer(toc_name, title='Temporary ' 'Transient Object Container', timeout_mins=20) session_data_manager = SessionDataManager(id=sdm_name, path='/' + tf_name + '/' + toc_name, title='Session Data Manager', requestName='TESTOFSESSION') try: app._delObject(idmgr_name) except (AttributeError, KeyError): pass try: app._delObject(tf_name) except (AttributeError, KeyError): pass try: app._delObject(sdm_name) except (AttributeError, KeyError): pass try: app._delObject('index_html') except (AttributeError, KeyError): pass app._setObject(idmgr_name, bidmgr) app._setObject(sdm_name, session_data_manager) app._setObject(tf_name, tf) transaction.commit() app.temp_folder._setObject(toc_name, toc) transaction.commit() # index_html necessary for publishing emulation for testAutoReqPopulate app._setObject('index_html', DTMLMethod('', __name__='foo')) transaction.commit()
def install_session_data_manager(self): app = self.getApp() if app._getInitializerFlag('session_data_manager'): # do nothing if we've already installed one return # Ensure that a session data manager exists if not hasattr(app, 'session_data_manager'): from Products.Sessions.SessionDataManager import SessionDataManager sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) # FIXME explicitely call manage_afterAdd, as sometimes # events are initialized too late session_data_manager = app.session_data_manager session_data_manager.manage_afterAdd(session_data_manager, app) app._setInitializerFlag('session_data_manager') self.commit('Added session_data_manager')
def install_session_data_manager(self): app = self.getApp() if app._getInitializerFlag('session_data_manager'): # do nothing if we've already installed one return # Ensure that a session data manager exists if not hasattr(app, 'session_data_manager'): from Products.Sessions.SessionDataManager import SessionDataManager sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) # Added for Five 1.2: session_data_manager = app.session_data_manager session_data_manager.manage_afterAdd(session_data_manager, app) # End added app._setInitializerFlag('session_data_manager') self.commit('Added session_data_manager')
def setupCoreSessions(app): '''Sets up the session_data_manager e.a.''' commit = 0 try: from Products.TemporaryFolder.TemporaryFolder import \ MountedTemporaryFolder from Products.Transience.Transience import TransientObjectContainer from Products.Sessions.BrowserIdManager import BrowserIdManager from Products.Sessions.SessionDataManager import SessionDataManager except ImportError: pass else: if not hasattr(app, 'temp_folder'): tf = MountedTemporaryFolder('temp_folder', 'Temporary Folder') app._setObject('temp_folder', tf) commit = 1 if not hasattr(aq_base(app.temp_folder), 'session_data'): toc = TransientObjectContainer('session_data', 'Session Data Container', timeout_mins=3, limit=100) app.temp_folder._setObject('session_data', toc) commit = 1 if not hasattr(app, 'browser_id_manager'): bid = BrowserIdManager('browser_id_manager', 'Browser Id Manager') app._setObject('browser_id_manager', bid) commit = 1 if not hasattr(app, 'session_data_manager'): sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) commit = 1 if commit: transaction.commit()
def setupCoreSessions(app=None): '''Sets up the session_data_manager e.a.''' from Acquisition import aq_base commit = 0 if app is None: return appcall(setupCoreSessions) if not hasattr(app, 'temp_folder'): from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder tf = MountedTemporaryFolder('temp_folder', 'Temporary Folder') app._setObject('temp_folder', tf) commit = 1 if not hasattr(aq_base(app.temp_folder), 'session_data'): from Products.Transience.Transience import TransientObjectContainer toc = TransientObjectContainer('session_data', 'Session Data Container', timeout_mins=3, limit=100) app.temp_folder._setObject('session_data', toc) commit = 1 if not hasattr(app, 'browser_id_manager'): from Products.Sessions.BrowserIdManager import BrowserIdManager bid = BrowserIdManager('browser_id_manager', 'Browser Id Manager') app._setObject('browser_id_manager', bid) commit = 1 if not hasattr(app, 'session_data_manager'): from Products.Sessions.SessionDataManager import SessionDataManager sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) commit = 1 if commit: transaction.commit()