Commit c0d06b71 authored by Jim Fulton's avatar Jim Fulton

removed dependency on zope.event, while retaining zope.event support

parent e17bbd1d
...@@ -197,7 +197,6 @@ setup(name="ZODB3", ...@@ -197,7 +197,6 @@ setup(name="ZODB3",
'zc.lockfile', 'zc.lockfile',
'ZConfig', 'ZConfig',
'zdaemon', 'zdaemon',
'zope.event',
'zope.interface', 'zope.interface',
], ],
zip_safe = False, zip_safe = False,
......
...@@ -5,6 +5,14 @@ ...@@ -5,6 +5,14 @@
3.11.0 (2010-??-??) 3.11.0 (2010-??-??)
=================== ===================
New Features
------------
- ZODB no-longer depends on zope.event. It now uses ZODB.event, which
uses zope.event if it is installed. You can override
ZODB.event.notify to provide your own event handling, although
zope.event is recommended.
Bugs Fixed Bugs Fixed
---------- ----------
......
...@@ -46,7 +46,7 @@ import ZEO.interfaces ...@@ -46,7 +46,7 @@ import ZEO.interfaces
import ZODB import ZODB
import ZODB.BaseStorage import ZODB.BaseStorage
import ZODB.interfaces import ZODB.interfaces
import zope.event import ZODB.event
import zope.interface import zope.interface
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -1384,7 +1384,7 @@ class ClientStorage(object): ...@@ -1384,7 +1384,7 @@ class ClientStorage(object):
self._cache.setLastTid(server_tid) self._cache.setLastTid(server_tid)
zope.event.notify(ZEO.interfaces.StaleCache(self)) ZODB.event.notify(ZEO.interfaces.StaleCache(self))
# From this point on, we do not have complete information about # From this point on, we do not have complete information about
# the missed transactions. The reason is that cache # the missed transactions. The reason is that cache
......
...@@ -56,14 +56,16 @@ And create another client and write some data to it: ...@@ -56,14 +56,16 @@ And create another client and write some data to it:
Now, we'll restart the server. Before we do that, we'll capture Now, we'll restart the server. Before we do that, we'll capture
logging and event data: logging and event data:
>>> import logging, zope.testing.loggingsupport, zope.event >>> import logging, zope.testing.loggingsupport, ZODB.event
>>> handler = zope.testing.loggingsupport.InstalledHandler( >>> handler = zope.testing.loggingsupport.InstalledHandler(
... 'ZEO.ClientStorage', level=logging.ERROR) ... 'ZEO.ClientStorage', level=logging.ERROR)
>>> events = [] >>> events = []
>>> def event_handler(e): >>> def event_handler(e):
... events.append(( ... events.append((
... len(e.storage._cache), str(handler), e.__class__.__name__)) ... len(e.storage._cache), str(handler), e.__class__.__name__))
>>> zope.event.subscribers.append(event_handler)
>>> old_notify = ZODB.event.notify
>>> ZODB.event.notify = event_handler
Note that the event handler is saving away the length of the cache and Note that the event handler is saving away the length of the cache and
the state of the log handler. We'll use this to show that the event the state of the log handler. We'll use this to show that the event
...@@ -213,4 +215,4 @@ invalidated during verification. ...@@ -213,4 +215,4 @@ invalidated during verification.
>>> db.close() >>> db.close()
>>> handler.uninstall() >>> handler.uninstall()
>>> zope.event.subscribers.remove(event_handler) >>> ZODB.event.notify = old_notify
...@@ -17,6 +17,7 @@ from persistent.mapping import PersistentMapping ...@@ -17,6 +17,7 @@ from persistent.mapping import PersistentMapping
from ZODB.POSException import ReadConflictError from ZODB.POSException import ReadConflictError
from ZODB.POSException import TransactionFailedError from ZODB.POSException import TransactionFailedError
import doctest
import transaction import transaction
import unittest import unittest
import ZODB import ZODB
...@@ -611,8 +612,10 @@ class PoisonedObject: ...@@ -611,8 +612,10 @@ class PoisonedObject:
self._p_jar = poisonedjar self._p_jar = poisonedjar
def test_suite(): def test_suite():
suite = unittest.makeSuite(ZODBTests, 'check') return unittest.TestSuite((
return suite unittest.makeSuite(ZODBTests, 'check'),
doctest.DocTestSuite('ZODB.event'),
))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(defaultTest="test_suite") unittest.main(defaultTest="test_suite")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment