[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/LocalEventService - LocalSubscriptionAware.py:1.3 PathSubscriber.py:1.4 configure.zcml:1.8
Jim Fulton
jim@zope.com
Thu, 11 Jul 2002 14:22:01 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/LocalEventService
In directory cvs.zope.org:/tmp/cvs-serv7355/lib/python/Zope/App/OFS/Services/LocalEventService
Modified Files:
LocalSubscriptionAware.py PathSubscriber.py configure.zcml
Log Message:
Reimplemented service managers to be package based. Service managers
are no longer containers. They have a packages subobject (not a
packages service) that contains packages. TTW components are created
in packages. To register a component, create the appropriate component
directive objects (these should be called configuration objects).
This should be viewed as a prototype to illustrate the idea of
packages. Lots of things can change (especially UI) and many things
aren't done (e.g. visiting created directives).
In the course of this, I fixed a bunch of bugs and problems in
traversal machinery.
I also renamed Zope.ComponentArchitecture.IServiceManager back to
IServiceService, since this interface doesn't actually specify any
management.
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscriptionAware.py 1.2 => 1.3 ===
Revision information:
$Id$
"""
+
from Zope.Event.ISubscriptionAware import ISubscriptionAware
from Zope.Proxy.ProxyIntrospection import removeAllProxies
-from Zope.ComponentArchitecture import getAdapter
-from Zope.App.Traversing.ITraverser import ITraverser
+from Zope.App.Traversing import getPhysicalPathString
class LocalSubscriptionAware:
@@ -31,22 +31,15 @@
self._subscriptions=()
def subscribedTo(self, subscribable, event_type, filter):
- #subscribable_path=getAdapter(
- # subscribable, ITraverser).getPhysicalPath()
- subscribable_path="/%s" % "/".join(getAdapter(
- subscribable, ITraverser).getPhysicalPath())
- # XXX right now the conversion to a string is necessary because
- # the tuple path returned by the Traverser does not include an
- # empty initial space to represent the root
+ subscribable_path = getPhysicalPathString(subscribable)
if (subscribable_path, event_type, filter) not in self._subscriptions:
self._subscriptions+=((subscribable_path,event_type, filter),)
def unsubscribedFrom(self, subscribable, event_type, filter):
- subscribable_path="/%s" % "/".join(getAdapter(
- subscribable, ITraverser).getPhysicalPath())
+ subscribable_path = getPhysicalPathString(subscribable)
sub=list(self._subscriptions)
sub.remove((subscribable_path, event_type, filter))
self._subscriptions=tuple(sub)
-
\ No newline at end of file
+
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/PathSubscriber.py 1.3 => 1.4 ===
from Zope.Proxy.ProxyIntrospection import removeAllProxies
from IPathSubscriber import IPathSubscriber
from Interface import Attribute
+from Zope.App.Traversing import getPhysicalPathString, traverse
from Zope.ContextWrapper import ContextMethod
@@ -32,21 +33,16 @@
__implements__=IPathSubscriber, ISubscriptionAware
def __init__(self, wrapped_subscriber):
- self.subscriber_path="/%s" % "/".join(getAdapter(
- wrapped_subscriber, ITraverser).getPhysicalPath())
- # XXX right now the conversion to a string is necessary because
- # the tuple path returned by the Traverser does not include an
- # empty initial space to represent the root
+ self.subscriber_path = getPhysicalPathString(wrapped_subscriber)
self.__alert_subscription=ISubscriptionAware.isImplementedBy(
removeAllProxies(wrapped_subscriber) )
def __eq__(self, other):
return IPathSubscriber.isImplementedBy(other) and \
- other.subscriber_path==self.subscriber_path
+ other.subscriber_path == self.subscriber_path
def __getSubscriber(self, wrapped_self):
- traverser = getAdapter(wrapped_self, ITraverser)
- return traverser.traverse(self.subscriber_path)
+ return traverse(wrapped_self, self.subscriber_path)
def notify(wrapped_self, event):
removeAllProxies(wrapped_self).__getSubscriber(
@@ -69,4 +65,4 @@
subscribable, event_type, filter )
unsubscribedFrom=ContextMethod(unsubscribedFrom)
-
\ No newline at end of file
+
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/configure.zcml 1.7 => 1.8 ===
attributes="bound unbound subscribe unsubscribe subscribeOnBind
unsubscribedFrom subscribedTo" />
</content>
+
+ <browser:menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
+ action="Events" title='Events'
+ description='An event service: use sparingly' />
<browser:icon name="zmi_icon" for=".LocalEventService.ILocalEventService"
file="./event_service.gif" />