[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ deleted missleading
copy/paste artefact observer.txt
Dominik Huber
dominik.huber at projekt01.ch
Wed May 19 05:45:59 EDT 2004
Log message for revision 24817:
deleted missleading copy/paste artefact observer.txt
removed unused imports and whitespaces
-=-
Modified: Zope3/trunk/src/zope/app/event/objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/objectevent.py 2004-05-19 09:37:20 UTC (rev 24816)
+++ Zope3/trunk/src/zope/app/event/objectevent.py 2004-05-19 09:45:58 UTC (rev 24817)
@@ -24,7 +24,6 @@
from zope.app.event.interfaces import IObjectAnnotationsModifiedEvent
from zope.app.event.interfaces import IObjectContentModifiedEvent
from zope.app.event.interfaces import ISubscriber
-from zope.app.observable.interfaces import IObservable
from zope.interface import implements
from zope.app.event import publish
from zope.app import zapi
Modified: Zope3/trunk/src/zope/app/event/tests/test_objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/tests/test_objectevent.py 2004-05-19 09:37:20 UTC (rev 24816)
+++ Zope3/trunk/src/zope/app/event/tests/test_objectevent.py 2004-05-19 09:45:58 UTC (rev 24817)
@@ -33,7 +33,6 @@
from zope.app.tests.placelesssetup import setUp, tearDown
from zope.app.servicenames import Adapters, EventPublication
from zope.component import getService
-from zope.app.observable.interfaces import IObservable
class TestObjectModifiedEvent(unittest.TestCase):
@@ -71,7 +70,7 @@
event = ObjectRemovedEvent(item)
notifier.notify(event)
self.assertEqual([event], events)
-
+
def testNotifyNobody(self):
# Check that notify won't raise an exception in absence of
# of subscribers.
Modified: Zope3/trunk/src/zope/app/observable/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/observable/interfaces.py 2004-05-19 09:37:20 UTC (rev 24816)
+++ Zope3/trunk/src/zope/app/observable/interfaces.py 2004-05-19 09:45:58 UTC (rev 24817)
@@ -16,14 +16,12 @@
$Id$
"""
-from zope.interface import implements
-from zope.interface.interfaces import Interface, IInterface
+from zope.interface.interfaces import Interface
class IObservable(Interface):
-
+
def notify(event, provided):
"""Notify all subscribers that the event provided has occured."""
def subscribe(required, provided, subscriber):
"""Subscribe to an event for a particular instance."""
-
Modified: Zope3/trunk/src/zope/app/observable/observable.py
===================================================================
--- Zope3/trunk/src/zope/app/observable/observable.py 2004-05-19 09:37:20 UTC (rev 24816)
+++ Zope3/trunk/src/zope/app/observable/observable.py 2004-05-19 09:45:58 UTC (rev 24817)
@@ -41,19 +41,16 @@
def unsubscribe(self, required, provided, subscriber):
annotations = IAnnotations(self.context)
registry = annotations.get(key)
-
+
if registry is not None:
# if there is no registry, we can't unsubscribe
registry.unsubscribe(required, provided, subscriber)
-
+
def notify(self, event, provided):
annotations = IAnnotations(self.context)
registry = annotations.get(key)
-
+
if registry is not None:
for subscriber in registry.subscriptions([providedBy(event)],
provided):
subscriber.notify(event)
-
-
-
Deleted: Zope3/trunk/src/zope/app/observable/observers.txt
===================================================================
--- Zope3/trunk/src/zope/app/observable/observers.txt 2004-05-19 09:37:20 UTC (rev 24816)
+++ Zope3/trunk/src/zope/app/observable/observers.txt 2004-05-19 09:45:58 UTC (rev 24817)
@@ -1,123 +0,0 @@
-=================
-Observer Registry
-=================
-
-Observer registries provide a way to register observers that depend on
-one or more interface specifications and provide (perhaps indirectly)
-some interface.
-
-The term "interface specification" refers both to interfaces and to
-interface declarations, such as declarations of interfaces implemented
-by a class.
-
-
-
- >>> from zope.interface.adapter import AdapterRegistry
- >>> import zope.interface
-
- >>> class IR1(zope.interface.Interface):
- ... pass
- >>> class IP1(zope.interface.Interface):
- ... pass
- >>> class IP2(IP1):
- ... pass
-
- >>> registry = AdapterRegistry()
-
-
- >>> class IR2(IR1):
- ... pass
- >>> registry.lookup([IR2], IP2, '')
- 12
-
- >>> class C2:
- ... zope.interface.implements(IR2)
-
-
-
- >>> class IP3(IP2):
- ... pass
-
-Normally, we want to look up an object that most-closely matches a
-specification. Sometimes, we want to get all of the objects that
-match some specification. We use subscriptions for this. We
-subscribe objects against specifications and then later find all of
-the subscribed objects::
-
- >>> registry.subscribe([IR1], IP2, 'sub12 1')
- >>> registry.subscriptions([IR1], IP2)
- ['sub12 1']
-
-Note that, unlike regular adapters, subscriptions are unnamed.
-
-The order of returned subscriptions is not specified.
-
-You can have multiple subscribers for the same specification::
-
- >>> registry.subscribe([IR1], IP2, 'sub12 2')
- >>> subs = registry.subscriptions([IR1], IP2)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2']
-
-You can register subscribers for all specifications using None::
-
- >>> registry.subscribe([None], IP1, 'sub_1')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2', 'sub_1']
-
-Subscriptions may be combined over multiple compatible specifications::
-
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2', 'sub_1']
- >>> registry.subscribe([IR1], IP1, 'sub11')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub11', 'sub12 1', 'sub12 2', 'sub_1']
- >>> registry.subscribe([IR2], IP2, 'sub22')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub11', 'sub12 1', 'sub12 2', 'sub22', 'sub_1']
- >>> subs = registry.subscriptions([IR2], IP2)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2', 'sub22']
-
-Subscriptions can be on multiple specifications::
-
- >>> registry.subscribe([IR1, IQ], IP2, 'sub1q2')
- >>> registry.subscriptions([IR1, IQ], IP2)
- ['sub1q2']
-
-As with single subscriptions and non-subscription adapters, you can
-specify None for the first required interface, to specify a default::
-
- >>> registry.subscribe([None, IQ], IP2, 'sub_q2')
- >>> registry.subscriptions([IS, IQ], IP2)
- ['sub_q2']
- >>> subs = registry.subscriptions([IR1, IQ], IP2)
- >>> subs.sort()
- >>> subs
- ['sub1q2', 'sub_q2']
-
-You can have subscriptions that are indepenent of any specifications::
-
- >>> registry.subscriptions([], IP1)
- []
-
- >>> registry.subscribe([], IP2, 'sub2')
- >>> registry.subscriptions([], IP1)
- ['sub2']
- >>> registry.subscribe([], IP1, 'sub1')
- >>> subs = registry.subscriptions([], IP1)
- >>> subs.sort()
- >>> subs
- ['sub1', 'sub2']
- >>> registry.subscriptions([], IP2)
- ['sub2']
More information about the Zope3-Checkins
mailing list