[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - SecurityAttributes.py:1.2 public.py:1.7

Shane Hathaway shane@zope.com
Sat, 1 Mar 2003 15:43:34 -0500


Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv29278/serial_ofs

Modified Files:
	SecurityAttributes.py public.py 
Log Message:
- Added SecurityAttributes, FSSecurityAttributes, and
SQLSecurityAttributes.  These classes store Zope 2 role names, local
roles, executable ownership, permission mappings, and proxy roles.
(Until now, all of this ended up in the remainder pickle.)

- Added a second abstract object mapper to Zope2Mapper.  The "base"
mapper has no properties aspect, while the "base_p" mapper does.  This
made Zope2FS and Zope2SQL a little cleaner, since they don't have to
remove the properties aspect.

- Added corresponding unit tests.


=== Products/AdaptableStorage/serial_ofs/SecurityAttributes.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_ofs/SecurityAttributes.py:1.1	Sat Mar  1 10:25:33 2003
+++ Products/AdaptableStorage/serial_ofs/SecurityAttributes.py	Sat Mar  1 15:43:02 2003
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2002 Zope Corporation and Contributors.
+# Copyright (c) 2003 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -32,6 +32,7 @@
     Does not discover permissions defined in ZClass products, since that
     would require access to the Zope application in the database.
     """
+    global _permission_dict_cache
     if _permission_dict_cache is not None:
         return _permission_dict_cache
     res = {}
@@ -58,6 +59,14 @@
 ##   "permission-no-acquire", "", permission_name, ""
 
 
+STANDARD_ROLES = {
+    'Anonymous': 1,
+    'Authenticated': 1,
+    'Manager': 1,
+    'Owner': 1,
+    }
+
+
 class SecurityAttributes:
 
     __implements__ = IAspectSerializer
@@ -90,7 +99,8 @@
         if roles is not None:
             event.ignoreAttribute('__ac_roles__')
             for role in roles:
-                res.append(('define-role', role, '', ''))
+                if not STANDARD_ROLES.has_key(role):
+                    res.append(('define-role', role, '', ''))
 
         local_roles = getattr(obj, '__ac_local_roles__', None)
         if local_roles is not None:
@@ -105,13 +115,13 @@
             for role in proxy_roles:
                 res.append(('proxy-role', role, '', ''))
 
-        pdict = None
-        for key, value in obj.__dict__.items():
-            if key.endswith('_Permission') and key.startswith('_'):
+        p_dict = None
+        for attr, value in obj.__dict__.items():
+            if attr.endswith('_Permission') and attr.startswith('_'):
                 if p_dict is None:
                     p_dict = getPermissionDict()
                 p = p_dict.get(attr)
-                if attr is not None:
+                if p is not None:
                     event.ignoreAttribute(attr)
                     for role in value:
                         res.append(('permission-role', role, p, ''))
@@ -193,11 +203,11 @@
         if local_roles:
             obj.__ac_local_roles__ = local_roles
         if defined_roles:
-            obj.__ac_roles = defined_roles
+            obj.__ac_roles__ = defined_roles
         if proxy_roles:
             obj._proxy_roles = proxy_roles
         
-        p, acquired in permission_acquired.items():
+        for p, acquired in permission_acquired.items():
             roles = permission_roles.get(p)
             if not acquired:
                 roles = tuple(roles)


=== Products/AdaptableStorage/serial_ofs/public.py 1.6 => 1.7 ===
--- Products/AdaptableStorage/serial_ofs/public.py:1.6	Mon Feb  3 13:26:50 2003
+++ Products/AdaptableStorage/serial_ofs/public.py	Sat Mar  1 15:43:02 2003
@@ -22,8 +22,9 @@
 from IdAttribute import IdAttribute
 from MetaTypeClassifier import MetaTypeClassifier
 from OFSProperties import OFSProperties
-from UserFolderSerializer import UserFolderSerializer
 from PythonScriptSerializer import PythonScriptSerializer
+from SecurityAttributes import SecurityAttributes
+from UserFolderSerializer import UserFolderSerializer
 from ZSQLMethodSerializer import ZSQLMethodSerializer, \
     ZSQLMethodPropertiesSerializer