[Checkins] SVN: z3c.davapp.zopelocking/trunk/src/z3c/davapp/zopelocking/indirecttokens.py Fix typo

Michael Kerrin michael.kerrin at openapp.ie
Tue Jun 12 14:48:22 EDT 2007


Log message for revision 76646:
  Fix typo
  

Changed:
  U   z3c.davapp.zopelocking/trunk/src/z3c/davapp/zopelocking/indirecttokens.py

-=-
Modified: z3c.davapp.zopelocking/trunk/src/z3c/davapp/zopelocking/indirecttokens.py
===================================================================
--- z3c.davapp.zopelocking/trunk/src/z3c/davapp/zopelocking/indirecttokens.py	2007-06-12 18:41:12 UTC (rev 76645)
+++ z3c.davapp.zopelocking/trunk/src/z3c/davapp/zopelocking/indirecttokens.py	2007-06-12 18:48:21 UTC (rev 76646)
@@ -322,7 +322,7 @@
       >>> indirecttoken.utility = util
       Traceback (most recent call last):
       ...
-      ValueError: Indirect tokens must be registered withsame utility has the root token
+      ValueError: Indirect tokens must be registered with the same utility has the root token
 
     Cleanup test.
 
@@ -353,7 +353,7 @@
                 root = self.roottoken
                 if root.utility != value:
                     raise ValueError("Indirect tokens must be registered with" \
-                                     "same utility has the root token")
+                                     " the same utility has the root token")
                 index = root.annotations.get(INDIRECT_INDEX_KEY, None)
                 if index is None:
                     index = root.annotations[INDIRECT_INDEX_KEY] = \
@@ -446,5 +446,17 @@
         roottoken.utility.register(token)
         del index[key_ref]
 
-# TODO - need subscriber incase a user tries to add a object has a
-# descendent to the lock object.
+
+# Can we restrict this further by saying only for certain types of objects.
+ at zope.component.adapter(
+    zope.interface.Interface, zope.app.container.interfaces.IObjectAddedEvent)
+def checkObjectAdded(object, event):
+    parent = object.__parent__
+    utility = zope.component.queryUtility(
+        zope.locking.interfaces.ITokenUtility, context = parent)
+    if utility:
+        token = utility.get(parent)
+        if token is not None:
+            if interfaces.IIndirectToken.providedBy(token):
+                token = token.roottoken
+            utility.register(IndirectToken(object, token))



More information about the Checkins mailing list