def setUp(self): self._oldSkindata = Skinnable.SKINDATA.copy() transaction.begin() app = self.app = makerequest(Zope2.app()) # Log in as a god :-) newSecurityManager(None, UnrestrictedUser('god', 'god', ['Manager'], '')) factory = app.manage_addProduct['CMFDefault'].addConfiguredSite factory('CalendarTest', 'CMFDefault:default', snapshot=False, extension_ids=('CMFCalendar:default', )) self.Site = app.CalendarTest self.Tool = app.CalendarTest.portal_calendar # sessioning setup if getattr(app, 'temp_folder', None) is None: temp_folder = MountedTemporaryFolder('temp_folder') app._setObject('temp_folder', temp_folder) if getattr(app.temp_folder, 'session_data', None) is None: session_data = TransientObjectContainer('session_data') app.temp_folder._setObject('session_data', session_data) app.REQUEST.set_lazy('SESSION', app.session_data_manager.getSessionData)
def setUp(self): self._trap_warning_output() transaction.begin() app = self.app = makerequest(Zope2.app()) # Log in as a god :-) newSecurityManager(None, UnrestrictedUser('god', 'god', ['Manager'], '')) app.manage_addProduct['CMFDefault'].manage_addCMFSite('CalendarTest') self.Site = app.CalendarTest manage_addExternalMethod(app.CalendarTest, id='install_events', title="Install Events", module="CMFCalendar.Install", function="install") ExMethod = app.restrictedTraverse('/CalendarTest/install_events') ExMethod() self.Tool = app.CalendarTest.portal_calendar self.Site.clearCurrentSkin() self.Site.setupCurrentSkin(app.REQUEST) # sessioning setup if getattr(app, 'temp_folder', None) is None: temp_folder = MountedTemporaryFolder('temp_folder') app._setObject('temp_folder', temp_folder) if getattr(app.temp_folder, 'session_data', None) is None: session_data = TransientObjectContainer('session_data') app.temp_folder._setObject('session_data', session_data) app.REQUEST.set_lazy('SESSION', app.session_data_manager.getSessionData)
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 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()
from ZODB import FileStorage import transaction from Products.Sessions.BrowserIdManager import BrowserIdManager from Products.Sessions.SessionDataManager import SessionDataManager from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder fs = FileStorage.FileStorage(os.path.join(Globals.data_dir, 'Data.fs.in')) db = DB(fs) conn = db.open() root = conn.root() app = root['Application'] print "Patching Data.fs.in" tf = MountedTemporaryFolder('temp_folder', 'Temporary Folder') app._setObject('temp_folder', tf) bid = BrowserIdManager('browser_id_manager', 'Browser Id Manager') app._setObject('browser_id_manager', bid) sdm = r.SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/transient_container', automatic=0) app._setObject('session_data_manager', sdm) app._p_changed = 1 transaction.commit()
def _makeOne(self, *args, **kw): from Products.TemporaryFolder.TemporaryFolder import \ MountedTemporaryFolder return MountedTemporaryFolder(*args, **kw)