[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/event. Oops, forgot to check these in when removing the dependency on zope.event
Jim Fulton
jim at zope.com
Fri Nov 18 14:15:47 UTC 2011
Log message for revision 123422:
Oops, forgot to check these in when removing the dependency on zope.event
Changed:
A ZODB/trunk/src/ZODB/event.py
A ZODB/trunk/src/ZODB/event.txt
-=-
Added: ZODB/trunk/src/ZODB/event.py
===================================================================
--- ZODB/trunk/src/ZODB/event.py (rev 0)
+++ ZODB/trunk/src/ZODB/event.py 2011-11-18 14:15:47 UTC (rev 123422)
@@ -0,0 +1,65 @@
+##############################################################################
+#
+# Copyright Zope Foundation 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.
+#
+##############################################################################
+
+def _noop(event):
+ """
+ Tests:
+
+ >>> import sys, ZODB.event
+ >>> notify = ZODB.event
+ >>> zopemod = sys.modules.get('zope', False)
+ >>> event = sys.modules.get('zope.event', False)
+ >>> if event:
+ ... del zopemod.event
+ ... sys.modules['zope.event'] = None
+ ... _ = reload(ZODB.event)
+
+ If zope.event isn't installed, then notify is _noop
+
+ >>> ZODB.event.notify is ZODB.event._noop
+ True
+
+ If zope.event is installed, then notify is zope.event.notify:
+
+ >>> zope = sys.modules['zope'] = type(sys)('zope')
+ >>> zope.event = sys.modules['zope.event'] = type(sys)('zope.event')
+ >>> zope.event.notify = lambda e: None
+ >>> _ = reload(ZODB.event)
+ >>> ZODB.event.notify is zope.event.notify
+ True
+
+ Cleanup:
+
+ >>> if event is False:
+ ... del sys.modules['zope.event']
+ ... else:
+ ... if event:
+ ... zopemod.event = event
+ ... sys.modules['zope.event'] = event
+
+ >>> if zopemod is False:
+ ... del sys.modules['zope']
+ ... else:
+ ... sys.modules['zope'] = zopemod
+
+ >>> ZODB.event.notify = notify
+
+ """
+ pass
+
+try:
+ from zope.event import notify
+except ImportError:
+ notify = _noop
+
Property changes on: ZODB/trunk/src/ZODB/event.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: ZODB/trunk/src/ZODB/event.txt
===================================================================
--- ZODB/trunk/src/ZODB/event.txt (rev 0)
+++ ZODB/trunk/src/ZODB/event.txt 2011-11-18 14:15:47 UTC (rev 123422)
@@ -0,0 +1,10 @@
+Event support
+
+Sometimes, you want to react when ZODB does certain things. In the
+past, ZODB provided ad hoc hook functions for this. Going forward,
+ZODB will use an event mechanism. ZODB.event.notify is called with
+events of interest.
+
+If zope.event is installed, then ZODB.event.notify is simply an alias
+for zope.event. If zope.event isn't installed, then ZODB.event is a
+noop.
Property changes on: ZODB/trunk/src/ZODB/event.txt
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Zodb-checkins
mailing list