[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Merge from 3.3 branch:

Philipp von Weitershausen philikon at philikon.de
Sat Aug 26 14:12:30 EDT 2006


Log message for revision 69787:
  Merge from 3.3 branch:
  
   Log message for revision 69785:
    Make adapter easier to register from Python and remove redudant info
    from ZCML accordingly.
    
    Unfortuantely, we can't add adapts()/adapter() declarations here because
    these adapters adapt persistent.interfaces.IPersistent.  Importing it
    isn't possible, however, because of Python's stupid relative import
    rule. THank God that's getting changed.
  
   Log message for revision 69786:
    Make subscribers easier to register from Python code and remove
    redundant info from ZCML accordingly.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/intid/__init__.py
  U   Zope3/trunk/src/zope/app/intid/configure.zcml
  U   Zope3/trunk/src/zope/app/keyreference/configure.zcml
  U   Zope3/trunk/src/zope/app/keyreference/persistent.py

-=-
Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/__init__.py	2006-08-26 18:06:12 UTC (rev 69786)
+++ Zope3/trunk/src/zope/app/intid/__init__.py	2006-08-26 18:12:27 UTC (rev 69787)
@@ -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/trunk/src/zope/app/intid/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/intid/configure.zcml	2006-08-26 18:06:12 UTC (rev 69786)
+++ Zope3/trunk/src/zope/app/intid/configure.zcml	2006-08-26 18:12:27 UTC (rev 69787)
@@ -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" />
 

Modified: Zope3/trunk/src/zope/app/keyreference/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/keyreference/configure.zcml	2006-08-26 18:06:12 UTC (rev 69786)
+++ Zope3/trunk/src/zope/app/keyreference/configure.zcml	2006-08-26 18:12:27 UTC (rev 69787)
@@ -2,7 +2,6 @@
 
   <adapter
       for="persistent.interfaces.IPersistent"
-      provides=".interfaces.IKeyReference"
       factory=".persistent.KeyReferenceToPersistent"
       trusted="y"
       />
@@ -13,7 +12,6 @@
 
   <adapter
       for="persistent.interfaces.IPersistent"
-      provides="ZODB.interfaces.IConnection"
       factory=".persistent.connectionOfPersistent"
       />
 

Modified: Zope3/trunk/src/zope/app/keyreference/persistent.py
===================================================================
--- Zope3/trunk/src/zope/app/keyreference/persistent.py	2006-08-26 18:06:12 UTC (rev 69786)
+++ Zope3/trunk/src/zope/app/keyreference/persistent.py	2006-08-26 18:12:27 UTC (rev 69787)
@@ -62,6 +62,7 @@
         return cmp(self.key_type_id, other.key_type_id)
 
 
+ at zope.interface.implementer(IConnection)
 def connectionOfPersistent(ob):
     """An adapter which gets a ZODB connection of a persistent object.
 



More information about the Zope3-Checkins mailing list