[Checkins] SVN: z3ext.preferences/trunk/ Remove principal annotations with principal

Nikolay Kim fafhrd91 at gmail.com
Tue Oct 20 02:06:45 EDT 2009


Log message for revision 105164:
  Remove principal annotations with principal

Changed:
  U   z3ext.preferences/trunk/CHANGES.txt
  U   z3ext.preferences/trunk/setup.py
  U   z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml
  U   z3ext.preferences/trunk/src/z3ext/preferences/storage.py

-=-
Modified: z3ext.preferences/trunk/CHANGES.txt
===================================================================
--- z3ext.preferences/trunk/CHANGES.txt	2009-10-20 06:05:18 UTC (rev 105163)
+++ z3ext.preferences/trunk/CHANGES.txt	2009-10-20 06:06:45 UTC (rev 105164)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+1.5.1 (2009-10-20)
+------------------
+
+- Remove principal annotations with principal
+
+
 1.5.0 (2009-08-13)
 ------------------
 

Modified: z3ext.preferences/trunk/setup.py
===================================================================
--- z3ext.preferences/trunk/setup.py	2009-10-20 06:05:18 UTC (rev 105163)
+++ z3ext.preferences/trunk/setup.py	2009-10-20 06:06:45 UTC (rev 105164)
@@ -21,7 +21,7 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-version='1.5.0dev'
+version='0'
 
 
 setup(name = 'z3ext.preferences',

Modified: z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml	2009-10-20 06:05:18 UTC (rev 105163)
+++ z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml	2009-10-20 06:06:45 UTC (rev 105164)
@@ -1,6 +1,7 @@
 <configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:i18n="http://namespaces.zope.org/i18n"
+   xmlns:zcml="http://namespaces.zope.org/zcml"
    xmlns:z3ext="http://namespaces.zope.org/z3ext"
    i18n_domain="z3ext.preferences">
 
@@ -58,6 +59,12 @@
      description="These are all the preferences related to portal membership."
      schema=".interfaces.IMembershipPreferences" />
 
+  <!-- removing principal event handler -->
+  <subscriber
+     for="z3ext.authentication.interfaces.IPrincipalRemovingEvent"
+     handler=".storage.principalRemovingHandler"
+     zcml:condition="installed z3ext.authentication" />
+
   <!-- browser views -->
   <include package=".browser" />
 

Modified: z3ext.preferences/trunk/src/z3ext/preferences/storage.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/storage.py	2009-10-20 06:05:18 UTC (rev 105163)
+++ z3ext.preferences/trunk/src/z3ext/preferences/storage.py	2009-10-20 06:06:45 UTC (rev 105164)
@@ -18,8 +18,12 @@
 from BTrees.OOBTree import OOBTree
 
 from zope import interface, component
+from zope.component import getUtility
+from zope.security.proxy import removeSecurityProxy
 from zope.security.interfaces import IPrincipal
 from zope.annotation.interfaces import IAnnotations
+from zope.app.principalannotation import PrincipalAnnotationUtility
+from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
 
 from interfaces import ANNOTATION_KEY, IDataStorage, IPreferenceGroup
 
@@ -61,3 +65,14 @@
     def __delattr__(self, attr):
         if attr in self.__btree__:
             del self.__btree__[attr]
+
+
+def principalRemovingHandler(event):
+    pid = event.principal.id
+    util = getUtility(IPrincipalAnnotationUtility)
+
+    if isinstance(util, PrincipalAnnotationUtility):
+        util = removeSecurityProxy(util)
+
+        if pid in util.annotations:
+            del util.annotations[pid]



More information about the checkins mailing list