[Checkins] SVN: zope.app.appsetup/trunk/ Move session bootstrap code into this package.
Dan Korostelev
nadako at gmail.com
Mon Mar 16 11:38:48 EDT 2009
Log message for revision 98143:
Move session bootstrap code into this package.
Changed:
U zope.app.appsetup/trunk/CHANGES.txt
U zope.app.appsetup/trunk/buildout.cfg
U zope.app.appsetup/trunk/setup.py
U zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml
A zope.app.appsetup/trunk/src/zope/app/appsetup/session.py
U zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py
-=-
Modified: zope.app.appsetup/trunk/CHANGES.txt
===================================================================
--- zope.app.appsetup/trunk/CHANGES.txt 2009-03-16 14:55:55 UTC (rev 98142)
+++ zope.app.appsetup/trunk/CHANGES.txt 2009-03-16 15:38:47 UTC (rev 98143)
@@ -10,6 +10,9 @@
functions, please remove the "asObject=True" argument passing anywhere,
because the support for that argument will be dropped soon.
+- Move session utility bootstrapping logic from ``zope.session`` into this
+ package. This removes a dependency from zope.session to this package.
+
- Remove one more deprecated function.
Modified: zope.app.appsetup/trunk/buildout.cfg
===================================================================
--- zope.app.appsetup/trunk/buildout.cfg 2009-03-16 14:55:55 UTC (rev 98142)
+++ zope.app.appsetup/trunk/buildout.cfg 2009-03-16 15:38:47 UTC (rev 98143)
@@ -1,5 +1,5 @@
[buildout]
-develop = .
+develop = .
parts = test python tags
[test]
Modified: zope.app.appsetup/trunk/setup.py
===================================================================
--- zope.app.appsetup/trunk/setup.py 2009-03-16 14:55:55 UTC (rev 98142)
+++ zope.app.appsetup/trunk/setup.py 2009-03-16 15:38:47 UTC (rev 98143)
@@ -61,6 +61,7 @@
'zope.event',
'zope.interface',
'zope.location',
+ 'zope.session',
'zope.site',
'zope.security',
'zope.traversing',
Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml 2009-03-16 14:55:55 UTC (rev 98142)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml 2009-03-16 15:38:47 UTC (rev 98143)
@@ -15,4 +15,9 @@
for="zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent"
/>
+ <subscriber
+ handler=".session.bootStrapSubscriber"
+ for="zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent"
+ />
+
</configure>
Copied: zope.app.appsetup/trunk/src/zope/app/appsetup/session.py (from rev 98142, zope.session/trunk/src/zope/session/bootstrap.py)
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/session.py (rev 0)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/session.py 2009-03-16 15:38:47 UTC (rev 98143)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2002-2009 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap code for sessions.
+
+$Id$
+"""
+
+import transaction
+
+from zope.app.appsetup.bootstrap import ensureUtility, getInformationFromEvent
+
+from zope.session.interfaces import IClientIdManager, ISessionDataContainer
+from zope.session.http import CookieClientIdManager
+from zope.session.session import PersistentSessionDataContainer
+
+def bootStrapSubscriber(event):
+ """Subscriber to the IDataBaseOpenedEvent
+
+ Create utility at that time if not yet present
+ """
+
+ db, connection, root, root_folder = getInformationFromEvent(event)
+
+ ensureUtility(
+ root_folder,
+ IClientIdManager, 'CookieClientIdManager',
+ CookieClientIdManager,
+ )
+ ensureUtility(
+ root_folder,
+ ISessionDataContainer, 'PersistentSessionDataContainer',
+ PersistentSessionDataContainer,
+ )
+
+ transaction.commit()
+ connection.close()
Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py 2009-03-16 14:55:55 UTC (rev 98142)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py 2009-03-16 15:38:47 UTC (rev 98143)
@@ -42,6 +42,9 @@
ensureObject, ensureUtility
from zope.app.appsetup.interfaces import DatabaseOpened
from zope.app.appsetup.errorlog import bootStrapSubscriber as errorlogBootStrapSubscriber
+from zope.app.appsetup.session import bootStrapSubscriber as sessionBootstrapSubscriber
+from zope.session.interfaces import IClientIdManager
+from zope.session.interfaces import ISessionDataContainer
from zope.app.testing import placelesssetup
@@ -182,7 +185,27 @@
# we need to close again in the end
connection.close()
+ def test_bootstrapSusbcriber(self):
+ self.createRFAndSM()
+
+ event = DatabaseOpened(self.db)
+ # this will open and close the database by itself
+ sessionBootstrapSubscriber(event)
+
+ db, connection, root, root_folder = getInformationFromEvent(event)
+
+ got_utility = zope.component.getUtility(IClientIdManager,
+ context=root_folder)
+ self.failUnless(IClientIdManager.providedBy(got_utility))
+
+ got_utility = zope.component.getUtility(ISessionDataContainer,
+ context=root_folder)
+ self.failUnless(ISessionDataContainer.providedBy(got_utility))
+ # we need to close again in the end
+ connection.close()
+
+
class TestConfigurationSchema(unittest.TestCase):
def setUp(self):
More information about the Checkins
mailing list