[Zope-Checkins] SVN: Zope/branches/ctheune-localrolemod/lib/python/AccessControl/Role.py - Fixed Role to support ComputedAttribute as local roles

Christian Theune ct at gocept.com
Thu Nov 25 09:20:05 EST 2004


Log message for revision 28504:
   - Fixed Role to support ComputedAttribute as local roles
  
  

Changed:
  U   Zope/branches/ctheune-localrolemod/lib/python/AccessControl/Role.py

-=-
Modified: Zope/branches/ctheune-localrolemod/lib/python/AccessControl/Role.py
===================================================================
--- Zope/branches/ctheune-localrolemod/lib/python/AccessControl/Role.py	2004-11-25 14:17:09 UTC (rev 28503)
+++ Zope/branches/ctheune-localrolemod/lib/python/AccessControl/Role.py	2004-11-25 14:20:04 UTC (rev 28504)
@@ -341,13 +341,15 @@
         """Set local roles for a user."""
         if not roles:
             raise ValueError, 'One or more roles must be given!'
-        dict=self.__ac_local_roles__ or {}
+        dict=self.__ac_local_roles__
+        if dict is None:
+            self.__ac_local_roles__ = dict = {}
         local_roles = list(dict.get(userid, []))
         for r in roles:
             if r not in local_roles:
                 local_roles.append(r)
         dict[userid] = local_roles
-        self.__ac_local_roles__=dict
+        self._p_changed=True
         if REQUEST is not None:
             stat='Your changes have been saved.'
             return self.manage_listLocalRoles(self, REQUEST, stat=stat)
@@ -356,20 +358,24 @@
         """Set local roles for a user."""
         if not roles:
             raise ValueError, 'One or more roles must be given!'
-        dict=self.__ac_local_roles__ or {}
+        dict=self.__ac_local_roles__
+        if dict is None:
+            self.__ac_local_roles__ = dict = {}
         dict[userid]=roles
-        self.__ac_local_roles__=dict
+        self._p_changed=True
         if REQUEST is not None:
             stat='Your changes have been saved.'
             return self.manage_listLocalRoles(self, REQUEST, stat=stat)
 
     def manage_delLocalRoles(self, userids, REQUEST=None):
         """Remove all local roles for a user."""
-        dict=self.__ac_local_roles__ or {}
+        dict=self.__ac_local_roles__
+        if dict is None:
+            self.__ac_local_roles__ = dict = {}
         for userid in userids:
             if dict.has_key(userid):
                 del dict[userid]
-        self.__ac_local_roles__=dict
+        self._p_changed=True
         if REQUEST is not None:
             stat='Your changes have been saved.'
             return self.manage_listLocalRoles(self, REQUEST, stat=stat)



More information about the Zope-Checkins mailing list