[Checkins] SVN: zope.component/branches/jinty-optional-event/src/zope/component/event.py Provide optional implementation of zope.event as a starting point.
Brian Sutherland
jinty at web.de
Thu Mar 4 10:41:36 EST 2010
Log message for revision 109650:
Provide optional implementation of zope.event as a starting point.
Changed:
U zope.component/branches/jinty-optional-event/src/zope/component/event.py
-=-
Modified: zope.component/branches/jinty-optional-event/src/zope/component/event.py
===================================================================
--- zope.component/branches/jinty-optional-event/src/zope/component/event.py 2010-03-04 15:37:24 UTC (rev 109649)
+++ zope.component/branches/jinty-optional-event/src/zope/component/event.py 2010-03-04 15:41:36 UTC (rev 109650)
@@ -19,13 +19,22 @@
__docformat__ = 'restructuredtext'
import zope.component.interfaces
-import zope.event
+try:
+ # use zope.event if it's around
+ from zope.event import subscribers, notify
+except ImportError:
+ # if not, provide our own implementation
+ subscribers = []
+ def notify(event):
+ for subscriber in subscribers:
+ subscriber(event)
+
def dispatch(*event):
zope.component.subscribers(event, None)
-zope.event.subscribers.append(dispatch)
+subscribers.append(dispatch)
@zope.component.adapter(zope.component.interfaces.IObjectEvent)
More information about the checkins
mailing list