[Zope3-checkins] SVN: Zope3/branches/3.3/src/zope/app/intid/ Make
subscribers easier to register from Python code and remove
Philipp von Weitershausen
philikon at philikon.de
Sat Aug 26 14:06:13 EDT 2006
Log message for revision 69786:
Make subscribers easier to register from Python code and remove
redundant info from ZCML accordingly.
Changed:
U Zope3/branches/3.3/src/zope/app/intid/__init__.py
U Zope3/branches/3.3/src/zope/app/intid/configure.zcml
-=-
Modified: Zope3/branches/3.3/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/intid/__init__.py 2006-08-26 18:04:06 UTC (rev 69785)
+++ Zope3/branches/3.3/src/zope/app/intid/__init__.py 2006-08-26 18:06:12 UTC (rev 69786)
@@ -29,8 +29,10 @@
from zope.interface import implements
from zope.security.proxy import removeSecurityProxy
from zope.location.interfaces import ILocation
+from zope.component import adapter, getAllUtilitiesRegisteredFor
-from zope.app import zapi
+from zope.app.container.interfaces import IObjectRemovedEvent
+from zope.app.container.interfaces import IObjectAddedEvent
from zope.app.container.contained import Contained
from zope.app.keyreference.interfaces import IKeyReference, NotYet
@@ -38,7 +40,6 @@
from zope.app.intid.interfaces import IntIdRemovedEvent
from zope.app.intid.interfaces import IntIdAddedEvent
-
class IntIds(Persistent, Contained):
"""This utility provides a two way mapping between objects and
integer ids.
@@ -130,14 +131,14 @@
del self.ids[key]
+ at adapter(ILocation, IObjectRemovedEvent)
def removeIntIdSubscriber(ob, event):
"""A subscriber to ObjectRemovedEvent
Removes the unique ids registered for the object in all the unique
id utilities.
"""
-
- utilities = tuple(zapi.getAllUtilitiesRegisteredFor(IIntIds))
+ utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
if utilities:
key = IKeyReference(ob, None)
# Register only objects that adapt to key reference
@@ -150,15 +151,14 @@
except KeyError:
pass
-
+ at adapter(ILocation, IObjectAddedEvent)
def addIntIdSubscriber(ob, event):
"""A subscriber to ObjectAddedEvent
Registers the object added in all unique id utilities and fires
an event for the catalogs.
"""
-
- utilities = tuple(zapi.getAllUtilitiesRegisteredFor(IIntIds))
+ utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
if utilities: # assert that there are any utilites
key = IKeyReference(ob, None)
# Register only objects that adapt to key reference
Modified: Zope3/branches/3.3/src/zope/app/intid/configure.zcml
===================================================================
--- Zope3/branches/3.3/src/zope/app/intid/configure.zcml 2006-08-26 18:04:06 UTC (rev 69785)
+++ Zope3/branches/3.3/src/zope/app/intid/configure.zcml 2006-08-26 18:06:12 UTC (rev 69786)
@@ -25,18 +25,9 @@
</localUtility>
- <subscriber
- handler=".removeIntIdSubscriber"
- for="zope.location.interfaces.ILocation
- zope.app.container.interfaces.IObjectRemovedEvent"
- />
+ <subscriber handler=".removeIntIdSubscriber" />
+ <subscriber handler=".addIntIdSubscriber" />
- <subscriber
- handler=".addIntIdSubscriber"
- for="zope.location.interfaces.ILocation
- zope.app.container.interfaces.IObjectAddedEvent"
- />
-
<!-- Views -->
<include package=".browser" />
More information about the Zope3-Checkins
mailing list