[Zope3-checkins] SVN: Zope3/branches/jim-simplifyevents/src/zope/app/ Changed subscribers to be handlers, meaning that most event handlers

Jim Fulton jim at zope.com
Wed May 26 07:27:38 EDT 2004


Log message for revision 24999:
Changed subscribers to be handlers, meaning that most event handlers
are now just simple handler functions.  This is a work in progress (on
this branch).



-=-
Modified: Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/bootstrap.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/bootstrap.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/bootstrap.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -26,11 +26,10 @@
 from zope.component.exceptions import ComponentLookupError
 
 from zope.app import zapi
-from zope.app.event.interfaces import ISubscriber
 from zope.app.traversing.api import traverse, traverseName
 from zope.app.publication.zopepublication import ZopePublication
 from zope.app.folder import rootFolder
-from zope.app.servicenames import HubIds, PrincipalAnnotation
+from zope.app.servicenames import PrincipalAnnotation
 from zope.app.servicenames import EventPublication, EventSubscription
 from zope.app.servicenames import ErrorLogging, Utilities
 from zope.app.site.service import ServiceManager, ServiceRegistration
@@ -41,13 +40,10 @@
 from zope.app.utility import UtilityRegistration, LocalUtilityService
 
 # XXX It should be possible to remove each of these from the basic
-# bootstrap, at which point we can remove the zope.app.hub,
+# bootstrap, at which point we can remove the
 # zope.app.principalannotation, and zope.app.session packages from
 # zope.app.
 
-from zope.app.hub import ObjectHub, Registration
-from zope.app.hub.interfaces import ISubscriptionControl
-
 from zope.app.principalannotation import PrincipalAnnotationService
 
 from zope.app.session.interfaces import \
@@ -63,8 +59,6 @@
     method.
     """
 
-    implements(ISubscriber)
-
     def doSetup(self):
         """Instantiate some service.
 
@@ -72,7 +66,7 @@
         """
         pass
 
-    def notify(self, event):
+    def __call__(self, event):
 
         db = event.database
         connection = db.open()
@@ -176,21 +170,6 @@
             name = zapi.getName(pub)
             configureService(self.root_folder, EventSubscription, name)
 
-        # Add the HubIds service, which subscribes itself to the event service
-        name = self.ensureService(HubIds, ObjectHub)
-        # Add a Registration object so that the Hub has something to do.
-        name = self.ensureObject('Registration',
-                                 ISubscriptionControl, Registration)
-
-        if name:
-            package = getServiceManagerDefault(self.root_folder)
-            reg = package[name]
-            # It's possible that we would want to reindex all objects when
-            # this is added - this seems like a very site-specific decision,
-            # though.
-            reg.subscribe()
-
-
         # Sundry other services
         self.ensureService(ErrorLogging,
                            RootErrorReportingService, copy_to_zlog=True)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/tests.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/tests.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/appsetup/tests.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -25,7 +25,6 @@
 from zope.app.errorservice.interfaces import IErrorReportingService
 from zope.app.principalannotation.interfaces import IPrincipalAnnotationService
 from zope.app.event.interfaces import IEventService
-from zope.app.hub.interfaces import IObjectHub
 from zope.app.publication.zopepublication import ZopePublication
 from zope.app.site.tests.placefulsetup import PlacefulSetup
 from zope.app.errorservice import ErrorReportingService
@@ -75,7 +74,7 @@
 
             setup()
 
-            BootstrapSubscriberBase().notify(EventStub(self.db))
+            BootstrapSubscriberBase()(EventStub(self.db))
 
             cx = self.db.open()
             root = cx.root()
@@ -92,7 +91,7 @@
 
         self.createRFAndSM()
         bs = BootstrapSubscriberBase()
-        bs.notify(EventStub(self.db))
+        bs(EventStub(self.db))
         for i in range(2):
             cx = self.db.open()
             name = bs.ensureService(ErrorLogging, ErrorReportingService)
@@ -118,7 +117,7 @@
     def test_bootstrapInstance(self):
         from zope.app.appsetup.bootstrap import bootstrapInstance
 
-        bootstrapInstance.notify(EventStub(self.db))
+        bootstrapInstance(EventStub(self.db))
 
         cx = self.db.open()
         root = cx.root()
@@ -130,9 +129,6 @@
         self.assert_(IEventService.providedBy(
             traverse(package, 'EventPublication')))
 
-        self.assert_(IObjectHub.providedBy(
-            traverse(package, 'HubIds')))
-
         self.assert_(IErrorReportingService.providedBy(
             traverse(package, 'ErrorLogging')))
 
@@ -151,7 +147,7 @@
                           ErrorReportingService, copy_to_zlog=True)
         configureService(self.root_folder, ErrorLogging, name)
 
-        bootstrapInstance.notify(EventStub(self.db))
+        bootstrapInstance(EventStub(self.db))
 
         cx = self.db.open()
         root = cx.root()
@@ -163,9 +159,6 @@
         self.assert_(IEventService.providedBy(
             traverse(package, 'EventPublication')))
 
-        self.assert_(IObjectHub.providedBy(
-            traverse(package, 'HubIds')))
-
         self.assertRaises(NotFoundError, traverse, root_folder,
                           '/++etc++site/default/ErrorLogging')
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/broken/broken.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/broken/broken.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/broken/broken.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -70,7 +70,7 @@
             return default
         return annotations.get(key, default)
 
-def installBroken(event):
+def installBrokenSubscriber(event):
     """Install a class factory that handled broken objects
 
     This method installs a custom class factory when it gets a
@@ -127,5 +127,3 @@
         return find_global(modulename, globalname, Broken_, type_)
 
     event.database.classFactory = classFactory
-
-installBrokenSubscriber = zope.app.event.function.Subscriber(installBroken)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/component/localservice.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/component/localservice.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/component/localservice.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -22,7 +22,6 @@
 from zope.component.interfaces import IServiceService
 from zope.proxy import removeAllProxies
 from zope.app.site.interfaces import ISite, ISiteManager
-from zope.app.event.interfaces import ISubscriber
 from zope.testing.cleanup import addCleanUp
 from zope.app.component.hooks import setSite
 
@@ -130,34 +129,22 @@
                                        " IServiceService" % (ob, ))
 
 
-class ThreadSiteSubscriber:
+def threadSiteSubscriber(event):
     """A subscriber to BeforeTraverseEvent
 
     Sets the 'site' thread global if the object traversed is a site.
     """
+    if ISite.providedBy(event.object):
+        setSite(event.object)
 
-    implements(ISubscriber)
-    def notify(self, event):
-        if ISite.providedBy(event.object):
-            setSite(event.object)
 
-
-threadSiteSubscriber = ThreadSiteSubscriber()
-
-
-class ClearThreadSiteSubscriber:
+def clearThreadSiteSubscriber(event):
     """A subscriber to EndRequestEvent
 
     Cleans up the site thread global after the request is processed.
     """
+    clearSite()
 
-    implements(ISubscriber)
-    def notify(self, event):
-        clearSite()
-
-clearThreadSiteSubscriber = ClearThreadSiteSubscriber()
-
-
 # Clear the site thread global
 clearSite = setSite
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/adapter.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/adapter.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/adapter.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -27,6 +27,10 @@
 class I3(zope.interface.Interface):
     pass
 
+class IS(zope.interface.Interface):
+    pass
+
+
 class Adapter:
     def __init__(self, *args):
         self.context = args
@@ -40,6 +44,7 @@
 class A3(Adapter):
     zope.interface.implements(I3)
 
+
 def Handler(content, *args):
     # uninteresting handler
     content.args = getattr(content, 'args', ()) + (args, )

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_directives.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_directives.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_directives.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -24,7 +24,6 @@
 from zope.testing.doctestunit import DocTestSuite
 from zope.app.component.metaconfigure import interface
 from zope.app.content.interfaces import IContentType
-from zope.app.event.interfaces import ISubscriber
 
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.configuration.exceptions import ConfigurationError
@@ -103,12 +102,13 @@
 
     def testSubscriber(self):
         from zope.app.component.tests.adapter import A1, A2, A3, I3
+        from zope.app.component.tests.adapter import IS
         from zope.component.tests.components import Content
 
         xmlconfig(StringIO(template % (
             """
             <subscriber
-              provides="zope.app.event.interfaces.ISubscriber"
+              provides="zope.app.component.tests.adapter.IS"
               factory="zope.app.component.tests.adapter.A3"
               for="zope.component.tests.components.IContent
                    zope.app.component.tests.adapter.I1"
@@ -118,7 +118,7 @@
 
         content = Content()
         a1 = A1()
-        subscribers = zapi.subscribers((content, a1), ISubscriber)
+        subscribers = zapi.subscribers((content, a1), IS)
 
         a3 = subscribers[0]
 
@@ -147,18 +147,19 @@
         
     def testMultiSubscriber(self):
         from zope.app.component.tests.adapter import A1, A2, A3, I3
+        from zope.app.component.tests.adapter import IS
         from zope.component.tests.components import Content
 
         xmlconfig(StringIO(template % (
             """
             <subscriber
-              provides="zope.app.event.interfaces.ISubscriber"
+              provides="zope.app.component.tests.adapter.IS"
               factory="zope.app.component.tests.adapter.A3"
               for="zope.component.tests.components.IContent
                    zope.app.component.tests.adapter.I1"
               />
             <subscriber
-              provides="zope.app.event.interfaces.ISubscriber"
+              provides="zope.app.component.tests.adapter.IS"
               factory="zope.app.component.tests.adapter.A2"
               for="zope.component.tests.components.IContent
                    zope.app.component.tests.adapter.I1"
@@ -168,7 +169,7 @@
 
         content = Content()
         a1 = A1()
-        subscribers = zapi.subscribers((content, a1), ISubscriber)
+        subscribers = zapi.subscribers((content, a1), IS)
 
         expectedLength = 2
         self.assertEqual(len(subscribers), expectedLength)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_localservice.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_localservice.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/component/tests/test_localservice.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -26,7 +26,6 @@
 from zope.component.service import serviceManager
 from zope.interface import implements, directlyProvides, directlyProvidedBy
 from zope.interface.verify import verifyObject
-from zope.app.event.interfaces import ISubscriber
 from zope.app.tests.setup import placelessSetUp, placelessTearDown
 from zope.app.tests import ztapi
 from zope.app.component.hooks import setSite, getSite
@@ -232,15 +231,13 @@
         from zope.app.component.localservice import clearSite
         from zope.app.publication.zopepublication import BeforeTraverseEvent
 
-        verifyObject(ISubscriber, threadSiteSubscriber)
-
         self.assertEqual(getSite(), None)
 
         # A non-site is traversed
         ob = object()
         request = object()
         ev = BeforeTraverseEvent(ob, request)
-        threadSiteSubscriber.notify(ev)
+        threadSiteSubscriber(ev)
 
         self.assertEqual(getSite(), None)
 
@@ -250,7 +247,7 @@
         site.setSiteManager(ss)
 
         ev = BeforeTraverseEvent(site, request)
-        threadSiteSubscriber.notify(ev)
+        threadSiteSubscriber(ev)
 
         self.assertEqual(getSite(), site)
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/configure.zcml
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/configure.zcml	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/configure.zcml	2004-05-26 11:27:37 UTC (rev 24999)
@@ -48,7 +48,6 @@
 
   <!-- Services -->
   <include package="zope.app.errorservice" />  
-  <include package="zope.app.hub" />  
   <include package="zope.app.menu" />  
   <include package="zope.app.pluggableauth" />  
   <include package="zope.app.site" />  

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/container/contained.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/container/contained.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/container/contained.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -232,20 +232,16 @@
     ...     def setMoved(self, event):
     ...         self.moved = event
 
-    >>> from zope.app.event.objectevent import objectEventCallbackHelper
     >>> from zope.app.container.interfaces import IObjectAddedEvent
     >>> from zope.app.container.interfaces import IObjectMovedEvent
-    >>> from zope.component import getService
-    >>> from zope.app.servicenames import Adapters
-    >>> from zope.app.event.interfaces import ISubscriber
-    >>> factory = objectEventCallbackHelper(
-    ...     lambda event: event.object.setAdded(event))
-    >>> getService(None, Adapters).subscribe(
-    ...     [IItem,IObjectAddedEvent], ISubscriber, factory)
-    >>> factory = objectEventCallbackHelper(
-    ...     lambda event: event.object.setMoved(event))
-    >>> getService(None, Adapters).subscribe(
-    ...     [IItem, IObjectMovedEvent], ISubscriber, factory)
+    >>> from zope.app.tests import ztapi
+
+    >>> ztapi.handle([IItem, IObjectAddedEvent],
+    ...              lambda event: event.object.setAdded(event))
+
+    >>> ztapi.handle([IItem, IObjectMovesEvent],
+    ...              lambda event: event.object.setMoved(event))
+    
     >>> item = Item()
 
     >>> container = {}

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/container/dependency.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/container/dependency.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/container/dependency.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -15,31 +15,19 @@
 
 $Id$
 """
-from zope.proxy import removeAllProxies
-from zope.interface import implements
 
 from zope.app import zapi
 from zope.app.dependable.interfaces import IDependable, DependencyError
-from zope.app.event.interfaces import ISubscriber
+from zope.proxy import removeAllProxies
 
-class DependencyChecker:
-    """Checking dependency  while deleting object
-    """
-    implements(ISubscriber)
-
-    def __init__(self):
-        pass
-
-    def notify(self, event):
-        object = removeAllProxies(event.object)
-        dependency = IDependable(object, None)
-        if dependency is not None:
-            dependents = dependency.dependents()
-            if dependents:
-                objectpath = zapi.getPath(event.object)
-                raise DependencyError("Removal of object (%s)"
-                                      " which has dependents (%s)"
-                                      % (objectpath,
-                                         ", ".join(dependents)))
-
-CheckDependency = DependencyChecker()
+def CheckDependency(event):
+    object = removeAllProxies(event.object)
+    dependency = IDependable(object, None)
+    if dependency is not None:
+        dependents = dependency.dependents()
+        if dependents:
+            objectpath = zapi.getPath(event.object)
+            raise DependencyError("Removal of object (%s)"
+                                  " which has dependents (%s)"
+                                  % (objectpath,
+                                     ", ".join(dependents)))

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/creatorannotator.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/creatorannotator.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/creatorannotator.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -16,27 +16,21 @@
 $Id$
 """
 from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.event.interfaces import ISubscriber
 from zope.security.management import queryInteraction
-from zope.interface import implements
 
-class CreatorAnnotatorClass(object):
+def CreatorAnnotator(event):
     """Update Dublin-Core creator property"""
-    implements(ISubscriber)
+    dc = IZopeDublinCore(event.object, None)
+    if dc is None:
+        return
 
-    def notify(self, event):
-        dc = IZopeDublinCore(event.object, None)
-        if dc is None:
-            return
+    # Try to find a principal for that one. If there
+    # is no principal then we don't touch the list
+    # of creators.
+    interaction = queryInteraction()
+    if interaction is not None:
+        for participation in interaction.participations:
+            principalid = participation.principal.id
+            if not principalid in dc.creators:
+                dc.creators = dc.creators + (unicode(principalid), )
 
-        # Try to find a principal for that one. If there
-        # is no principal then we don't touch the list
-        # of creators.
-        interaction = queryInteraction()
-        if interaction is not None:
-            for participation in interaction.participations:
-                principalid = participation.principal.id
-                if not principalid in dc.creators:
-                    dc.creators = dc.creators + (unicode(principalid), )
-
-CreatorAnnotator = CreatorAnnotatorClass()

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/tests/test_creatorannotator.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/tests/test_creatorannotator.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/tests/test_creatorannotator.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -96,13 +96,13 @@
 
         # Check what happens if no user is there
         newInteraction(None)
-        CreatorAnnotator.notify(event)
+        CreatorAnnotator(event)
         self.assertEqual(data.creators,())
         endInteraction()
 
         # Let the bad edit it first
         newInteraction(DummyRequest(bad_author))
-        CreatorAnnotator.notify(event)
+        CreatorAnnotator(event)
 
         self.failIf(len(data.creators) != 1)
         self.failUnless(bad_author.id in data.creators)
@@ -110,7 +110,7 @@
 
         # Now let the good edit it
         newInteraction(DummyRequest(good_author))
-        CreatorAnnotator.notify(event)
+        CreatorAnnotator(event)
 
         self.failIf(len(data.creators) != 2)
         self.failUnless(good_author.id in data.creators)
@@ -119,7 +119,7 @@
 
         # Let the bad edit it again
         newInteraction(DummyRequest(bad_author))
-        CreatorAnnotator.notify(event)
+        CreatorAnnotator(event)
 
         # Check that the bad author hasn't been added twice.
         self.failIf(len(data.creators) != 2)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/timeannotators.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/timeannotators.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/dublincore/timeannotators.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -19,38 +19,15 @@
 
 from datetime import datetime
 from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.event.interfaces import ISubscriber
-from zope.interface import implements
 
-class DCTimeAnnotatorBase:
-    """Update Dublin-Core time property
-    """
-    implements(ISubscriber)
-
-    def notify(self, event):
-        dc = IZopeDublinCore(event.object, None)
-        if dc is not None:
-            self.annotate(dc)
-
-    def annotate(self, dc):
-        raise RuntimeError, 'annotate not implemented'
-
-
-class ModifiedAnnotatorClass(DCTimeAnnotatorBase):
-    """Updates DC modified when an object is modified."""
-
-    def annotate(self, dc):
+def ModifiedAnnotator(event):
+    dc = IZopeDublinCore(event.object, None)
+    if dc is not None:
         dc.modified = datetime.utcnow()
 
-
-class CreatedAnnotatorClass(DCTimeAnnotatorBase):
-    """Sets DC created and modified when an object is created."""
-
-    def annotate(self, dc):
+def CreatedAnnotator(event):
+    dc = IZopeDublinCore(event.object, None)
+    if dc is not None:
         now = datetime.utcnow()
         dc.created = now
         dc.modified = now
-
-
-ModifiedAnnotator = ModifiedAnnotatorClass()
-CreatedAnnotator = CreatedAnnotatorClass()

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/configure.zcml
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/configure.zcml	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/configure.zcml	2004-05-26 11:27:37 UTC (rev 24999)
@@ -11,9 +11,10 @@
     serviceType="EventPublication"
     component="zope.app.event.globalservice.eventPublisher" />
 
-<event:subscribe
-    subscriber=".objectevent.objectEventNotifierInstance"
-    event_types="zope.app.event.interfaces.IObjectEvent" />
+<subscriber
+    for="zope.app.event.interfaces.IObjectEvent" 
+    factory=".objectevent.objectEventNotify"
+    />
 
 <!-- Local Event Service -->
 <content class=".localservice.EventService">

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/objectevent.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/objectevent.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/objectevent.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -23,7 +23,6 @@
 from zope.app.event.interfaces import IObjectCopiedEvent
 from zope.app.event.interfaces import IObjectAnnotationsModifiedEvent
 from zope.app.event.interfaces import IObjectContentModifiedEvent
-from zope.app.event.interfaces import ISubscriber
 from zope.interface import implements
 from zope.app.event import publish
 from zope.component import subscribers
@@ -73,37 +72,8 @@
     implements(IObjectCopiedEvent)
 
 
-class ObjectEventNotifier:
+def objectEventNotify(event):
     """Event subscriber to dispatch ObjectEvents to interested adapters."""
-    implements(ISubscriber)
-
-    def notify(self, event):
-        assert IObjectEvent.providedBy(event)
-        adapters = subscribers((event.object, event), ISubscriber)
-        for adapter in adapters:
-            adapter.notify(event)
-
-objectEventNotifierInstance = ObjectEventNotifier()
-
-def objectEventCallbackHelper(callback):
-    """Build a factory implementing ISubscriber that just calls a callback
-
-    callback will be called with an ObjectEvent instance. Example usage:
-
-    factory = objectEventCallbackHelper(events.append)
-    getService(None, Adapters).subscribe(
-        [MyObjectType, IObjectRemovedEvent], ISubscriber, factory
-    )
-    """
-    class _CallbackHelper:
-        implements(ISubscriber)           
-        def __init__(self, object, event):
-            self.object = object
-            self.event = event
-
-        def notify(self, event):
-            callback(event)
-
-    return _CallbackHelper
-
-
+    adapters = subscribers((event.object, event), None)
+    for adapter in adapters:
+        pass # getting them does the work

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -28,11 +28,9 @@
 from zope.app.container.contained import Contained, ObjectRemovedEvent
 from zope.app.container.interfaces import IContained, IObjectRemovedEvent
 from zope.app.container.interfaces import IObjectEvent
-from zope.app.event.interfaces import ISubscriber
 from zope.app.container.sample import SampleContainer
 from zope.app.tests.placelesssetup import setUp, tearDown
-from zope.app.servicenames import Adapters, EventPublication
-from zope.component import getService
+from zope.app.tests import ztapi
 
 class TestObjectModifiedEvent(unittest.TestCase):
 
@@ -61,10 +59,7 @@
         notifier = objectevent.ObjectEventNotifier()
         events = []
 
-        factory = objectevent.objectEventCallbackHelper(events.append)
-        getService(None, Adapters).subscribe(
-            [IContained, IObjectRemovedEvent], ISubscriber, factory
-        )
+        ztapi.handle([IContained, IObjectRemovedEvent], events.append)
 
         item = Contained()
         event = ObjectRemovedEvent(item)
@@ -82,9 +77,7 @@
         self.assertEqual([], events)
 
     def testVeto(self):
-        eventPublication = getService(None, EventPublication)
-        eventPublication.globalSubscribe(objectevent.ObjectEventNotifier(),
-                                         IObjectEvent)
+        ztapi.handle([IObjectEvent], objectevent.objectEventNotify)
         container = SampleContainer()
         item = Contained()
 
@@ -99,10 +92,7 @@
             self.assertEqual(item, event.object)
             raise Veto
 
-        factory = objectevent.objectEventCallbackHelper(callback)
-        getService(None, Adapters).subscribe(
-            [IContained, IObjectRemovedEvent], ISubscriber, factory
-        )
+        ztapi.handle([IContained, IObjectRemovedEvent], callback)
 
         # del container['Fred'] will fire an ObjectRemovedEvent event.
         self.assertRaises(Veto, container.__delitem__, 'Fred')

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/generations/generations.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/generations/generations.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/generations/generations.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -18,7 +18,6 @@
 
 from interfaces import GenerationTooHigh, GenerationTooLow, UnableToEvolve
 from interfaces import ISchemaManager
-from zope.app.event.interfaces import ISubscriber
 import logging
 import os
 import zope.interface
@@ -352,18 +351,13 @@
         conn.close()
 
 
-class EvolveSubscriber:
 
-    zope.interface.implements(ISubscriber)
+def evolveSubscriber(event):
+    evolve(event.database, EVOLVE)
 
-    def __init__(self, flag):
-        self.flag = flag
+def evolveNotSubscriber(event):
+    evolve(event.database, EVOLVENOT)
 
-    def notify(self, event):
-        evolve(event.database, self.flag)
+def evolveMinimumSubscriber(event):
+    evolve(event.database, EVOLVEMINIMUM)
 
-
-evolveSubscriber = EvolveSubscriber(EVOLVE)
-evolveNotSubscriber = EvolveSubscriber(EVOLVENOT)
-evolveMinimumSubscriber = EvolveSubscriber(EVOLVEMINIMUM)
-

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/module/__init__.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/module/__init__.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/module/__init__.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -108,6 +108,3 @@
 def installPersistentModuleImporter(event):
     from zodbcode.module import PersistentModuleImporter
     PersistentModuleImporter().install()
-
-installPersistentModuleImporter = function.Subscriber(
-    installPersistentModuleImporter)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/observable/configure.zcml
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/observable/configure.zcml	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/observable/configure.zcml	2004-05-26 11:27:37 UTC (rev 24999)
@@ -4,7 +4,7 @@
     >
 
 <event:subscribe
-    subscriber=".observerevent.observerEventNotifierInstance"
+    subscriber=".observerevent.observerEventNotifier"
     event_types="zope.app.event.interfaces.IObjectEvent" />
 
 </configure>

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/observable/observerevent.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/observable/observerevent.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/observable/observerevent.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -16,19 +16,10 @@
 $Id$
 """
 
-from zope.app.event.interfaces import ISubscriber
 from zope.app.observable.interfaces import IObservable
-from zope.interface import implements
 
-class ObserverEventNotifier:
+def observerEventNotifier(event):
+    adapter = IObservable(event.object, None)
+    if adapter is not None:
+        adapter.notify(event)
 
-    implements(ISubscriber)
-
-    def notify (self, event):
-        adapter = IObservable(event.object, None)
-
-        if adapter is not None:
-            adapter.notify(event)
-
-observerEventNotifierInstance = ObserverEventNotifier()
-

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/pluggableauth/__init__.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/pluggableauth/__init__.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/pluggableauth/__init__.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -186,60 +186,45 @@
         del self[id]
 
 
-class PluggableAuthenticationServiceAddSubscriber:
+def PluggableAuthenticationServiceAddSubscriber(self, event):
+    r"""Generates an earmark if one is not provided.
 
-    zope.interface.implements(zope.app.event.interfaces.ISubscriber)
+    Define a stub for PluggableAuthenticationService
 
-    def __init__(self, pluggable_auth_service, event):
-        self.pluggable_auth_service = pluggable_auth_service
-        self.event = event
+    >>> from zope.app.traversing.interfaces import IPhysicallyLocatable
+    >>> class PluggableAuthStub:
+    ...     implements(IPhysicallyLocatable)
+    ...     def __init__(self, earmark=None):
+    ...         self.earmark = earmark
+    ...     def getName(self):
+    ...         return 'PluggableAuthName'
 
-    def notify(self, event):
-        r"""Generates an earmark if one is not provided.
+    The subscriber generates an earmark for the auth service if one is not
+    set in the init.
 
-        Define a stub for PluggableAuthenticationService
+    >>> stub = PluggableAuthStub()
+    >>> event = ''
+    >>> PluggableAuthenticationServiceAddSubscriber(stub, event)
+    >>> stub.earmark is not None
+    True
 
-        >>> from zope.app.traversing.interfaces \
-        ...     import IPhysicallyLocatable
-        >>> class PluggableAuthStub:
-        ...     implements(IPhysicallyLocatable)
-        ...     def __init__(self, earmark=None):
-        ...         self.earmark = earmark
-        ...     def getName(self):
-        ...         return 'PluggableAuthName'
+    The subscriber does not modify an earmark for the auth service if one
+    exists already.
 
-        The subscriber generates an earmark for the auth service if one is not
-        set in the init.
-
-        >>> stub = PluggableAuthStub()
-        >>> event = ''
-        >>> subscriber = \
-        ...     PluggableAuthenticationServiceAddSubscriber(stub,
-        ...                                                 event)
-        >>> subscriber.notify(event)
-        >>> stub.earmark is not None
-        True
-        
-        The subscriber does not modify an earmark for the auth service if one
-        exists already.
-
-        >>> earmark = 'my sample earmark'
-        >>> stub = PluggableAuthStub(earmark=earmark)
-        >>> event = ''
-        >>> subscriber = \
-        ...     PluggableAuthenticationServiceAddSubscriber(stub, event)
-        >>> subscriber.notify(event)
-        >>> stub.earmark == earmark
-        True
-        """
-        self = self.pluggable_auth_service
-        if self.earmark is None:
-            # we manufacture what is intended to be a globally unique
-            # earmark if one is not provided in __init__
-            myname = zapi.name(self)
-            rand_id = gen_key()
-            t = int(time.time())
-            self.earmark = '%s-%s-%s' % (myname, rand_id, t)
+    >>> earmark = 'my sample earmark'
+    >>> stub = PluggableAuthStub(earmark=earmark)
+    >>> event = ''
+    >>> PluggableAuthenticationServiceAddSubscriber(stub, event)
+    >>> stub.earmark == earmark
+    True
+    """
+    if self.earmark is None:
+        # we manufacture what is intended to be a globally unique
+        # earmark if one is not provided in __init__
+        myname = zapi.name(self)
+        rand_id = gen_key()
+        t = int(time.time())
+        self.earmark = '%s-%s-%s' % (myname, rand_id, t)
                 
 
 class IBTreePrincipalSource(

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/presentation/presentation.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/presentation/presentation.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/presentation/presentation.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -473,37 +473,21 @@
 
     factory = property(factory)
 
-class PageRegistrationAddSubscriber(object):
-    implements(zope.app.event.interfaces.ISubscriber)
+def PageRegistrationAddSubscriber(self, event):
+    if self.template:
+        template = zapi.traverse(self.__parent__.__parent__,self.template)
+        dependents = IDependable(template)
+        objectpath = zapi.getPath(self)
+        dependents.addDependent(objectpath)
 
-    def __init__(self, page_registration, event):
-        self.page_registration = page_registration
-        self.event = event
-        
-    def notify(self, event):
-        self = self.page_registration
-        if self.template:
-            template = zapi.traverse(self.__parent__.__parent__,self.template)
-            dependents = IDependable(template)
-            objectpath = zapi.getPath(self)
-            dependents.addDependent(objectpath)
 
+def PageRegistrationRemoveSubscriber(self, event):
+    if self.template:
+        template = zapi.traverse(self.__parent__.__parent__,self.template)
+        dependents = IDependable(template)
+        objectpath = zapi.getPath(self)
+        dependents.removeDependent(objectpath)
 
-class PageRegistrationRemoveSubscriber(object):
-    implements(zope.app.event.interfaces.ISubscriber)
-
-    def __init__(self, page_registration, event):
-        self.page_registration = page_registration
-        self.event = event
-
-    def notify(self, event):
-        self = self.page_registration
-        if self.template:
-            template = zapi.traverse(self.__parent__.__parent__,self.template)
-            dependents = IDependable(template)
-            objectpath = zapi.getPath(self)
-            dependents.removeDependent(objectpath)
-
 #XXX can't make new-style class b/c of unpickling error...
 class TemplateViewFactory:
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/presentation/tests/test_presentation.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/presentation/tests/test_presentation.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/presentation/tests/test_presentation.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -26,7 +26,6 @@
 
 from zope.app.container.interfaces import IObjectAddedEvent
 from zope.app.container.interfaces import IObjectRemovedEvent
-from zope.app.event.interfaces import ISubscriber
 from zope.app.folder import rootFolder
 from zope.app.presentation.zpt import IZPTTemplate
 from zope.app.site.service import ServiceManager
@@ -462,8 +461,8 @@
     def test_registerAddSubscriber_template(self):
         ztapi.provideAdapter(ILocation, IPhysicallyLocatable,
                              PhonyPathAdapter)
-        ztapi.subscribe((IPageRegistration, IObjectAddedEvent), ISubscriber,
-                        PageRegistrationAddSubscriber)
+        ztapi.handle((IPageRegistration, IObjectAddedEvent),
+                     PageRegistrationAddSubscriber)
         registration = PageRegistration(I1, 'test', 'zope.View', "Foo.Bar.A",
                                         template='/++etc++site/default/t')
         
@@ -475,8 +474,8 @@
     def test_registerRemoveSubscriber_template(self):
         ztapi.provideAdapter(ILocation, IPhysicallyLocatable,
                              PhonyPathAdapter)
-        ztapi.subscribe((IPageRegistration, IObjectRemovedEvent), ISubscriber,
-                        PageRegistrationRemoveSubscriber)
+        ztapi.handle((IPageRegistration, IObjectRemovedEvent),
+                     PageRegistrationRemoveSubscriber)
         registration = PageRegistration(I1, 'test', 'zope.View', "Foo.Bar.A",
                                         template='/++etc++site/default/t')
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/servicenames.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/servicenames.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/servicenames.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -25,5 +25,4 @@
 EventPublication = 'EventPublication'
 EventSubscription = 'Subscription'
 ErrorLogging = 'ErrorLogging'
-HubIds = 'HubIds'
 PrincipalAnnotation = 'PrincipalAnnotation'

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/site/service.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/site/service.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/site/service.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -41,7 +41,6 @@
 from zope.app.container.constraints import ItemTypePrecondition
 from zope.app.container.contained import Contained
 from zope.app.container.interfaces import IContainer
-from zope.app.event.function import Subscriber
 from zope.app.registration.interfaces import IRegistry
 from zope.app.traversing.interfaces import IContainmentRoot
 from zope.app.traversing.api import getPath

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/site/tests/placefulsetup.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/site/tests/placefulsetup.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/site/tests/placefulsetup.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -75,14 +75,7 @@
     def createRootFolder(self):
         self.rootFolder = rootFolder()
 
-    # The following is a hook that some base classes might want to override.
-    def getObjectHub(self):
-        from zope.app.hub import ObjectHub
-        return ObjectHub()
-
     def createStandardServices(self):
         '''Create a bunch of standard placeful services'''
 
-        setup.createStandardServices(self.rootFolder,
-                                     hubids=self.getObjectHub())
-
+        setup.createStandardServices(self.rootFolder)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/tests/setup.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/tests/setup.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/tests/setup.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -182,14 +182,12 @@
     zapi.traverse(default.getRegistrationManager(), key).status = ActiveStatus
     return zapi.traverse(servicemanager, path)
 
-from zope.app.hub.interfaces import IObjectHub
 from zope.app.event.interfaces import ISubscriptionService
 from zope.app.event.localservice import EventService
-from zope.app.hub import ObjectHub
 from zope.app.utility import LocalUtilityService
-from zope.app.servicenames import HubIds, Utilities
+from zope.app.servicenames import Utilities
 from zope.app.servicenames import EventPublication, EventSubscription
-def createStandardServices(folder, hubids=None):
+def createStandardServices(folder):
     '''Create a bunch of standard placeful services
 
     Well, uh, 3
@@ -202,16 +200,10 @@
     # EventPublication service already defined by
     # zope.app.events.tests.PlacelessSetup
 
-    defineService(HubIds, IObjectHub)
-
     # EventService must be IAttributeAnnotatable so that it can support
     # dependencies.
     classImplements(EventService, IAttributeAnnotatable)
     events = EventService()
     addService(sm, EventPublication, events)
     addService(sm, EventSubscription, events, suffix='sub')
-    if hubids is None:
-        hubids = ObjectHub()
 
-    addService(sm, HubIds, hubids)
-

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/tests/ztapi.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/tests/ztapi.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/tests/ztapi.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -74,6 +74,9 @@
     s = zapi.getGlobalServices().getService(Adapters)
     s.subscribe(required, provided, factory)
 
+def handle(required, handler):
+    subscribe(required, None, handler)
+
 def provideUtility(provided, component, name=''):
     s = zapi.getGlobalServices().getService(Utilities)
     s.provideUtility(provided, component, name)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/undo/__init__.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/undo/__init__.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -31,8 +31,6 @@
     svc = zapi.getGlobalService(Utilities)
     svc.provideUtility(IUndoManager, ZODBUndoManager(event.database))
 
-undoSetup = function.Subscriber(undoSetup)
-
 class Prefix(str):
     """A prefix is equal to any string it is a prefix of.
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/wiki/browser/wiki.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/wiki/browser/wiki.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/wiki/browser/wiki.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -20,7 +20,6 @@
 
 from zope.app import zapi
 from zope.app.dublincore.interfaces import ICMFDublinCore
-from zope.app.servicenames import HubIds
 from zope.app.traversing.api import getName, getPath
 from zope.app.container.browser.adding import Adding
 from zope.app.hub import Registration
@@ -32,15 +31,6 @@
 
     def createAndAdd(self, data):
         content = super(AddWiki, self).createAndAdd(data)
-        if self.request.get('textindex'):
-            # Get the environment
-            sm = zapi.getServices()
-            pkg = sm['default']
-            # Create, subscribe and add a Registration object.
-            if 'WikiReg' not in pkg: 
-                reg = Registration()
-                pkg['WikiReg'] = reg
-                reg.subscribe()
 
         if self.request.get('frontpage'):
             page = removeAllProxies(

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/wiki/tests/test_wikimail.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/wiki/tests/test_wikimail.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/wiki/tests/test_wikimail.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -22,7 +22,6 @@
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.site.tests.placefulsetup import PlacefulSetup
 from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.event.interfaces import ISubscriber
 from zope.app.event.objectevent import ObjectModifiedEvent
 from zope.app.annotation.attribute import AttributeAnnotations
 from zope.app.mail.interfaces import IMailDelivery
@@ -129,9 +128,6 @@
         ztapi.provideUtility(IMailDelivery, delivery,
                              name='wiki-delivery')
 
-    def test_Interface(self):
-        self.failUnless(ISubscriber.providedBy(mailer))
-
     def test_getAllSubscribers(self):
         wiki = Wiki()
         wiki_sub = MailSubscriptions(wiki)
@@ -155,7 +151,7 @@
         wiki['page1'] = page
         page.source = 'Hello World!'
         event = ObjectModifiedEvent(page)
-        mailer.notify(event)
+        mailer(event)
         self.assertEqual('wiki at zope3.org', 
                          mail_result[0][0])
         self.assertEqual(('blah at bar.com', 'foo at bar.com'), mail_result[0][1])

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/wiki/wikipage.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/wiki/wikipage.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/wiki/wikipage.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -25,7 +25,7 @@
 from zope.app.dublincore.interfaces import ICMFDublinCore
 from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
 from zope.app.annotation.interfaces import IAnnotations
-from zope.app.event.interfaces import ISubscriber, IObjectModifiedEvent
+from zope.app.event.interfaces import IObjectModifiedEvent
 from zope.app.container.interfaces import \
      IObjectAddedEvent, IObjectRemovedEvent, IObjectMovedEvent
 from zope.app.mail.interfaces import IMailDelivery
@@ -208,15 +208,13 @@
 class WikiMailer:
     """Class to handle all outgoing mail."""
 
-    implements(ISubscriber)
-
     def __init__(self, host="localhost", port="25"):
         """Initialize the the object.""" 
         self.host = host
         self.port = port
 
-    def notify(self, event):
-        """See zope.app.event.interfaces.ISubscriber"""
+    def __call__(self, event):
+        # XXX event handling should be separated from mailing
         if IWikiPage.providedBy(event.object):
             if IObjectAddedEvent.providedBy(event):
                 self.handleAdded(event.object)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -21,7 +21,6 @@
 from persistent.dict import PersistentDict
 
 from zope.app import zapi
-from zope.app.event.interfaces import ISubscriber
 from zope.app.event.interfaces import IObjectCreatedEvent
 from zope.app.servicenames import EventSubscription, Utilities
 
@@ -33,41 +32,29 @@
 from zope.app.container.contained import Contained
 
 
-class NewObjectProcessInstanceCreator(object):
-    implements(ISubscriber)
-    
-    __used_for__ = (IProcessInstanceContainerAdaptable, IObjectCreatedEvent)
+def NewObjectProcessInstanceCreator(obj, event):
+    #  used for: IProcessInstanceContainerAdaptable, IObjectCreatedEvent
 
-    __slots__ = ('event', )
+    pi_container = IProcessInstanceContainer(obj)
 
-    def __init__(self, obj, event):
-        self.event = event
+    for (ignored, cwf) in zapi.getUtilitiesFor(IContentWorkflowsManager):
+        # here we will lookup the configured processdefinitions
+        # for the newly created compoent. For every pd_name
+        # returned we will create a processinstance.
 
-    def notify(self, ignored_event):
-        """See zope.app.event.interfaces.ISubscriber"""
-        event = self.event
-        obj = event.object
+        # Note that we use getUtilitiesFor rather than getAllUtilitiesFor
+        # so that we don't use overridden content-workflow managers.
 
-        pi_container = IProcessInstanceContainer(obj)
+        for pd_name in cwf.getProcessDefinitionNamesForObject(obj):
 
-        for (ignored, cwf) in zapi.getUtilitiesFor(IContentWorkflowsManager):
-            # here we will lookup the configured processdefinitions
-            # for the newly created compoent. For every pd_name
-            # returned we will create a processinstance.
-
-            # Note that we use getUtilitiesFor rather than getAllUtilitiesFor
-            # so that we don't use overridden content-workflow managers.
-            
-            for pd_name in cwf.getProcessDefinitionNamesForObject(obj):
-
-                if pd_name in pi_container.keys():
-                    continue
-                try:
-                    pi = createProcessInstance(cwf, pd_name)
-                except KeyError:
-                    # No registered PD with that name..
-                    continue
-                pi_container[pd_name] = pi
+            if pd_name in pi_container.keys():
+                continue
+            try:
+                pi = createProcessInstance(cwf, pd_name)
+            except KeyError:
+                # No registered PD with that name..
+                continue
+            pi_container[pd_name] = pi
         
 
 class ContentWorkflowsManager(Persistent, Contained):

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/tests/test_contentworkflow.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/tests/test_contentworkflow.py	2004-05-26 11:26:21 UTC (rev 24998)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/tests/test_contentworkflow.py	2004-05-26 11:27:37 UTC (rev 24999)
@@ -27,7 +27,7 @@
 from zope.app.event.tests.placelesssetup import eventPublisher, EventRecorder
 from zope.app.event.tests.placelesssetup import clearEvents
 from zope.app.annotation.interfaces import IAnnotatable, IAttributeAnnotatable
-from zope.app.event.interfaces import IObjectCreatedEvent, ISubscriber
+from zope.app.event.interfaces import IObjectCreatedEvent
 from zope.app.utility import UtilityRegistration
 from zope.app.utility.interfaces import ILocalUtility
 from zope.app.registration.interfaces import ActiveStatus




More information about the Zope3-Checkins mailing list