[Checkins] SVN: AccessControl/trunk/ merge part of r114789 to AccessControl

David Glick davidglick at onenw.org
Fri Jul 16 02:10:42 EDT 2010


Log message for revision 114791:
  merge part of r114789 to AccessControl

Changed:
  U   AccessControl/trunk/CHANGES.txt
  U   AccessControl/trunk/src/AccessControl/security.py

-=-
Modified: AccessControl/trunk/CHANGES.txt
===================================================================
--- AccessControl/trunk/CHANGES.txt	2010-07-16 06:07:43 UTC (rev 114790)
+++ AccessControl/trunk/CHANGES.txt	2010-07-16 06:10:42 UTC (rev 114791)
@@ -4,6 +4,7 @@
 2.13.2 (unreleased)
 -------------------
 
+- Added ``override_existing_protection`` parameter to the protectName helper.
 
 2.13.1 (2010-06-19)
 -------------------

Modified: AccessControl/trunk/src/AccessControl/security.py
===================================================================
--- AccessControl/trunk/src/AccessControl/security.py	2010-07-16 06:07:43 UTC (rev 114790)
+++ AccessControl/trunk/src/AccessControl/security.py	2010-07-16 06:10:42 UTC (rev 114791)
@@ -121,12 +121,15 @@
     return security
 
 
-def protectName(klass, name, permission_id):
+def protectName(klass, name, permission_id, override_existing_protection=True):
     """Protect the attribute 'name' on 'klass' using the given
        permission"""
     security = _getSecurity(klass)
     # Zope 2 uses string, not unicode yet
     name = str(name)
+    if not override_existing_protection and ('%s__roles__' % name) in dir(klass):
+        # There is already a declaration for this name from a base class.
+        return
     if permission_id == CheckerPublicId or permission_id is CheckerPublic:
         # Sometimes, we already get a processed permission id, which
         # can mean that 'zope.Public' has been interchanged for the



More information about the checkins mailing list