[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/server/ Register
datanases as utilities.
Jim Fulton
jim at zope.com
Sat Jun 4 09:00:45 EDT 2005
Log message for revision 30643:
Register datanases as utilities.
Changed:
U Zope3/trunk/src/zope/app/server/main.py
U Zope3/trunk/src/zope/app/server/tests/test_server.py
-=-
Modified: Zope3/trunk/src/zope/app/server/main.py
===================================================================
--- Zope3/trunk/src/zope/app/server/main.py 2005-06-04 12:44:03 UTC (rev 30642)
+++ Zope3/trunk/src/zope/app/server/main.py 2005-06-04 13:00:44 UTC (rev 30643)
@@ -22,8 +22,12 @@
from zdaemon import zdoptions
+import ZODB.interfaces
+
import ThreadedAsync
+from zope import component, interface
+
import zope.app.appsetup
import zope.app.appsetup.interfaces
from zope.event import notify
@@ -92,10 +96,17 @@
>>> [d.databases is m for d in s]
[True, True, True]
- >>> m = m.items()
- >>> m.sort()
- >>> m
+ >>> items = m.items()
+ >>> items.sort()
+ >>> items
[('', DB(3)), ('x', DB(1)), ('y', DB(2))]
+
+ Each of the databases is registered as an IDatabase utility:
+
+ >>> [(component.getUtility(ZODB.interfaces.IDatabase, name) is m[name])
+ ... for name in m]
+ [True, True, True]
+
"""
databases = {}
@@ -108,6 +119,11 @@
db.databases = databases
db.database_name = name
databases[name] = db
+ # Grrr bug in ZODB. Database doesn't declare that it implements
+ # IDatabase.
+ if not ZODB.interfaces.IDatabase.providedBy(db):
+ interface.directlyProvides(db, ZODB.interfaces.IDatabase)
+ component.provideUtility(db, ZODB.interfaces.IDatabase, name)
result.append(db)
return result, databases
Modified: Zope3/trunk/src/zope/app/server/tests/test_server.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_server.py 2005-06-04 12:44:03 UTC (rev 30642)
+++ Zope3/trunk/src/zope/app/server/tests/test_server.py 2005-06-04 13:00:44 UTC (rev 30643)
@@ -19,7 +19,7 @@
from zope.interface.verify import verifyObject
from zope.testing import doctest
-from zope.app.testing import ztapi, setup
+from zope.app.testing import ztapi, setup, placelesssetup
def doctest_ServerFactory():
@@ -87,7 +87,9 @@
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite(),
- doctest.DocTestSuite('zope.app.server.main'),
+ doctest.DocTestSuite(
+ 'zope.app.server.main',
+ setUp=placelesssetup.setUp, tearDown=placelesssetup.tearDown),
))
More information about the Zope3-Checkins
mailing list