[Zope-Checkins] CVS: Releases/Zope/lib/python/OFS - Application.py:1.161
Matthew T. Kromer
matt@zope.com
Tue, 13 Nov 2001 17:02:47 -0500
Update of /cvs-repository/Releases/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv24650/lib/python/OFS
Modified Files:
Application.py
Log Message:
Add Temporary Folder, Transience, and Sessions in application init
=== Releases/Zope/lib/python/OFS/Application.py 1.160 => 1.161 ===
get_transaction().commit()
+
+ # b/c: Ensure that a temp folder exists
+ if not hasattr(app, 'temp_folder'):
+ from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder
+ tf = MountedTemporaryFolder('temp_folder','Temporary Folder')
+ app._setObject('temp_folder', tf)
+ get_transaction().note('Added temp_folder')
+ get_transaction().commit()
+ del tf
+
+ # b/c: Ensure that there is a transient container in the temp folder
+ tf = app.temp_folder
+ if not hasattr(tf, 'transient_container'):
+ from Products.Transience.Transience import TransientObjectContainer
+
+ addnotify = os.environ.get('ZSESSION_ADD_NOTIFY', '/session_add')
+ delnotify = os.environ.get('ZSESSION_DEL_NOTIFY', '/session_del')
+ if app.unrestrictedTraverse(addnotify,None) is None: addnotify=None
+ if app.unrestrictedTraverse(delnotify,None) is None: delnotify=None
+
+ toc = TransientObjectContainer('transient_container',
+ 'Transient Object Container', addNotification=addnotify,
+ delNotification = delnotify)
+ tf._setObject('transient_container', toc)
+ get_transaction().note('Added transient_container to '
+ 'temp_folder')
+ get_transaction().commit()
+ del toc
+ del addnotify
+ del delnotify
+
+ del tf
+
+ # b/c: Ensure that a browser ID manager exists
+ 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)
+ get_transaction().note('Added browser_id_manager')
+ get_transaction().commit()
+ del bid
+
+ # b/c: 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/transient_container',
+ requestName='SESSION')
+ app._setObject('session_data_manager', sdm)
+ get_transaction().note('Added session_data_manager')
+ get_transaction().commit()
+ del sdm
+
# b/c: Ensure that Owner role exists.
if hasattr(app, '__ac_roles__') and not ('Owner' in app.__ac_roles__):
app.__ac_roles__=app.__ac_roles__ + ('Owner',)