[Zope3-checkins] SVN: Zope3/branches/jim-simplifyevents/src/zope/app/event/ Added partial implementation of adapter-based event dispatching

Jim Fulton jim at zope.com
Wed May 26 07:20:19 EDT 2004


Log message for revision 24994:
Added partial implementation of adapter-based event dispatching



-=-
Added: Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py	2004-05-26 11:18:20 UTC (rev 24993)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py	2004-05-26 11:20:19 UTC (rev 24994)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##############################################################################
+"""Implement zope-specific event dispatching, based on subscription adapters
+
+This package instals an event dispatcher that calls event handlers,
+registered as subscription adapters providing None.
+
+So, to subscribe to an event, use a subscription adapter to None:
+
+  >>> from zope.app.tests.placelesssetup import SetUp, tearDown
+  >>> setUp()
+
+  >>> class E1:
+  ...     pass
+
+  >>> class E2(E1):
+  ...     pass
+
+  >>> called = []
+  >>> def handler1(event):
+  ...     called.append(1)
+
+  >>> def handler2(event):
+  ...     called.append(2)
+
+  >>> from zope.app.tests import ztapi
+  >>> ztapi.subscribe(E1, None, handler1)
+  >>> ztapi.subscribe(E2, None, handler2)
+
+  >>> from zope.event import notify
+
+  >>> notify(E1())
+  >>> called
+  [1]
+
+  >>> del called[:]
+  >>> notify(E2())
+  >>> called.sort()
+  >>> called
+  [1, 2]
+  
+  >>> tearDown()
+
+$Id$
+"""


Property changes on: Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_dispatching.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_dispatching.py	2004-05-26 11:18:20 UTC (rev 24993)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_dispatching.py	2004-05-26 11:20:19 UTC (rev 24994)
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##############################################################################
+"""Test the event dispatching code
+
+$Id$
+"""
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+
+
+def test_suite():
+    return unittest.TestSuite((
+        DocTestSuite('zope.app.event.dispatching'),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_dispatching.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native




More information about the Zope3-Checkins mailing list