[Zope-Checkins] SVN: Zope/branches/hannosch-dtml-vs-accesscontrol/src/ Move InitializeClass into AccessControl
Hanno Schlichting
hannosch at hannosch.eu
Sun May 16 16:00:04 EDT 2010
Log message for revision 112388:
Move InitializeClass into AccessControl
Changed:
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Owned.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/PermissionMapping.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Role.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/SecurityInfo.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/User.py
A Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/class_init.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/metaconfigure.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/securitySuite/regressionSecurity.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testAcquisition.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testBindings.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testClassSecurityInfo.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZCML.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZopeGuards.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/App/class_init.py
U Zope/branches/hannosch-dtml-vs-accesscontrol/src/Globals/__init__.py
-=-
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Owned.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Owned.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Owned.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -21,10 +21,10 @@
from Acquisition import aq_inner
from Acquisition import aq_parent
from App.special_dtml import DTMLFile
-from App.class_init import InitializeClass
from ExtensionClass import Base
from zope.interface import implements
+from AccessControl.class_init import InitializeClass
from AccessControl.interfaces import IOwned
from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import take_ownership
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/PermissionMapping.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/PermissionMapping.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/PermissionMapping.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -22,10 +22,10 @@
from cgi import escape
from Acquisition import ImplicitAcquisitionWrapper
-from App.class_init import InitializeClass
from ExtensionClass import Base
from zope.interface import implements
+from AccessControl.class_init import InitializeClass
from AccessControl.interfaces import IPermissionMappingSupport
from AccessControl.Owned import UnownableOwner
from AccessControl.Permission import pname
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Role.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Role.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/Role.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -22,13 +22,13 @@
from AccessControl import ClassSecurityInfo
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.Permissions import change_permissions
-from App.class_init import InitializeClass
from App.Dialogs import MessageDialog
from App.special_dtml import DTMLFile
from ExtensionClass import Base
from PermissionMapping import RoleManager
from zope.interface import implements
+from AccessControl.class_init import InitializeClass
from AccessControl.interfaces import IRoleManager
from AccessControl.Permission import Permission
from AccessControl.requestmethod import requestmethod
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/SecurityInfo.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/SecurityInfo.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/SecurityInfo.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -311,5 +311,5 @@
sec.declareObjectPublic()
sec.setDefaultAccess(1)
sec.apply(Class)
- from App.class_init import InitializeClass
+ from AccessControl.class_init import InitializeClass
InitializeClass(Class)
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/User.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/User.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/User.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -24,12 +24,12 @@
from Acquisition import aq_parent
from Acquisition import aq_inContextOf
from Acquisition import Implicit
-from App.class_init import InitializeClass
from App.Management import Navigation
from App.Management import Tabs
from App.special_dtml import DTMLFile
from App.Dialogs import MessageDialog
from AccessControl import ClassSecurityInfo
+from AccessControl.class_init import InitializeClass
from AccessControl.Permissions import manage_users as ManageUsers
from OFS.SimpleItem import Item
from Persistence import Persistent
Copied: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/class_init.py (from rev 112374, Zope/branches/hannosch-dtml-vs-accesscontrol/src/App/class_init.py)
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/class_init.py (rev 0)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/class_init.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -0,0 +1,89 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Class initialization.
+
+$Id$
+"""
+
+import logging
+
+from AccessControl.Permission import ApplicationDefaultPermissions # BBB
+
+def InitializeClass(self):
+ from AccessControl.Permission import registerPermissions
+ from AccessControl.PermissionRole import PermissionRole
+ dict=self.__dict__
+ have=dict.has_key
+ ft=type(InitializeClass)
+ dict_items=dict.items()
+
+ for name, v in dict_items:
+ if getattr(v, '_need__name__', 0):
+ d = v.__dict__
+ oldname = d.get('__name__', '')
+ if d.get('_implicit__name__', 0):
+ # Already supplied a name.
+ if name != oldname:
+ # Tried to implicitly assign a different name!
+ try: classname = '%s.%s' % (
+ self.__module__, self.__name__)
+ except AttributeError: classname = `self`
+ logging.getLogger("Init").warning(
+ 'Ambiguous name for method of %s: %r != %r',
+ classname, d['__name__'], name)
+ else:
+ # Supply a name implicitly so that the method can
+ # find the security assertions on its container.
+ v._implicit__name__ = 1
+ v.__name__ = name
+ if name=='manage' or name[:7]=='manage_':
+ name=name+'__roles__'
+ if not have(name):
+ setattr(self, name, ('Manager',))
+ elif name=='manage' or name[:7]=='manage_' and type(v) is ft:
+ name=name+'__roles__'
+ if not have(name):
+ setattr(self, name, ('Manager',))
+
+ # Look for a SecurityInfo object on the class. If found, call its
+ # apply() method to generate __ac_permissions__ for the class. We
+ # delete the SecurityInfo from the class dict after it has been
+ # applied out of paranoia.
+ for key, value in dict_items:
+ if hasattr(value, '__security_info__'):
+ security_info=value
+ security_info.apply(self)
+ delattr(self, key)
+ break
+
+ if self.__dict__.has_key('__ac_permissions__'):
+ registerPermissions(self.__ac_permissions__)
+ for acp in self.__ac_permissions__:
+ pname, mnames = acp[:2]
+ if len(acp) > 2:
+ roles = acp[2]
+ pr = PermissionRole(pname, roles)
+ else:
+ pr = PermissionRole(pname)
+ for mname in mnames:
+ setattr(self, mname+'__roles__', pr)
+ if (mname and mname not in ('context', 'request') and
+ not hasattr(self, mname)):
+ # don't complain about context or request, as they are
+ # frequently not available as class attributes
+ logging.getLogger("Init").warning(
+ "Class %s.%s has a security declaration for "
+ "nonexistent method %r", self.__module__,
+ self.__name__, mname)
+
+default__class_init__ = InitializeClass # BBB: old name
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/metaconfigure.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/metaconfigure.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/metaconfigure.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -14,8 +14,8 @@
import warnings
from zope.security import metaconfigure
+from AccessControl.class_init import InitializeClass
from AccessControl.security import protectName
-from App.class_init import InitializeClass
class ClassDirective(metaconfigure.ClassDirective):
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/securitySuite/regressionSecurity.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/securitySuite/regressionSecurity.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/securitySuite/regressionSecurity.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -15,15 +15,14 @@
import unittest
+from AccessControl.class_init import InitializeClass
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.User import nobody
from AccessControl.securitySuite import SecurityBase
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
-from App.class_init import InitializeClass
-
# let's define some permissions first
MAGIC_PERMISSION1 = 'Magic Permission 1'
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testAcquisition.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testAcquisition.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testAcquisition.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -25,8 +25,8 @@
Zope2.startup()
from OFS.SimpleItem import SimpleItem
-from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo
+from AccessControl.class_init import InitializeClass
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.Permissions import view, view_management_screens
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testBindings.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testBindings.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testBindings.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -21,7 +21,7 @@
import transaction
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
-from App.class_init import InitializeClass
+from AccessControl.class_init import InitializeClass
from OFS.ObjectManager import ObjectManager
from OFS.Folder import Folder
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testClassSecurityInfo.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testClassSecurityInfo.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testClassSecurityInfo.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -28,7 +28,7 @@
# Test setting default roles for permissions.
- from App.class_init import InitializeClass
+ from AccessControl.class_init import InitializeClass
from ExtensionClass import Base
ClassSecurityInfo = self._getTargetClass()
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZCML.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZCML.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZCML.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -109,7 +109,7 @@
>>> from zope.configuration.xmlconfig import xmlconfig
>>> xmlconfig(configure_zcml)
- >>> from App.class_init import InitializeClass
+ >>> from AccessControl.class_init import InitializeClass
>>> InitializeClass(Dummy2)
Now we compare their access controls:
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZopeGuards.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZopeGuards.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/AccessControl/tests/testZopeGuards.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -583,9 +583,9 @@
def _getProtectedBaseClass(self):
+ from AccessControl.class_init import InitializeClass
from AccessControl.SecurityInfo import ClassSecurityInfo
from ExtensionClass import Base
- from App.class_init import InitializeClass
global _ProtectedBase
if _ProtectedBase is None:
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/App/class_init.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/App/class_init.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/App/class_init.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -11,79 +11,9 @@
#
##############################################################################
"""Class initialization.
-
-$Id$
"""
-import logging
-
-from AccessControl.Permission import ApplicationDefaultPermissions # BBB
-
-def InitializeClass(self):
- from AccessControl.Permission import registerPermissions
- from AccessControl.PermissionRole import PermissionRole
- dict=self.__dict__
- have=dict.has_key
- ft=type(InitializeClass)
- dict_items=dict.items()
-
- for name, v in dict_items:
- if getattr(v, '_need__name__', 0):
- d = v.__dict__
- oldname = d.get('__name__', '')
- if d.get('_implicit__name__', 0):
- # Already supplied a name.
- if name != oldname:
- # Tried to implicitly assign a different name!
- try: classname = '%s.%s' % (
- self.__module__, self.__name__)
- except AttributeError: classname = `self`
- logging.getLogger("Init").warning(
- 'Ambiguous name for method of %s: %r != %r',
- classname, d['__name__'], name)
- else:
- # Supply a name implicitly so that the method can
- # find the security assertions on its container.
- v._implicit__name__ = 1
- v.__name__ = name
- if name=='manage' or name[:7]=='manage_':
- name=name+'__roles__'
- if not have(name):
- setattr(self, name, ('Manager',))
- elif name=='manage' or name[:7]=='manage_' and type(v) is ft:
- name=name+'__roles__'
- if not have(name):
- setattr(self, name, ('Manager',))
-
- # Look for a SecurityInfo object on the class. If found, call its
- # apply() method to generate __ac_permissions__ for the class. We
- # delete the SecurityInfo from the class dict after it has been
- # applied out of paranoia.
- for key, value in dict_items:
- if hasattr(value, '__security_info__'):
- security_info=value
- security_info.apply(self)
- delattr(self, key)
- break
-
- if self.__dict__.has_key('__ac_permissions__'):
- registerPermissions(self.__ac_permissions__)
- for acp in self.__ac_permissions__:
- pname, mnames = acp[:2]
- if len(acp) > 2:
- roles = acp[2]
- pr = PermissionRole(pname, roles)
- else:
- pr = PermissionRole(pname)
- for mname in mnames:
- setattr(self, mname+'__roles__', pr)
- if (mname and mname not in ('context', 'request') and
- not hasattr(self, mname)):
- # don't complain about context or request, as they are
- # frequently not available as class attributes
- logging.getLogger("Init").warning(
- "Class %s.%s has a security declaration for "
- "nonexistent method %r", self.__module__,
- self.__name__, mname)
-
+# BBB
+from AccessControl.Permission import ApplicationDefaultPermissions
+from AccessControl.class_init import InitializeClass
default__class_init__ = InitializeClass # BBB: old name
Modified: Zope/branches/hannosch-dtml-vs-accesscontrol/src/Globals/__init__.py
===================================================================
--- Zope/branches/hannosch-dtml-vs-accesscontrol/src/Globals/__init__.py 2010-05-16 19:58:44 UTC (rev 112387)
+++ Zope/branches/hannosch-dtml-vs-accesscontrol/src/Globals/__init__.py 2010-05-16 20:00:03 UTC (rev 112388)
@@ -34,8 +34,8 @@
PersistentMapping = 'Persistence:PersistentMapping',
)
-deprecated("import from App.class_init instead",
- InitializeClass = 'App.class_init:InitializeClass',
+deprecated("import from AccessControl.class_init instead",
+ InitializeClass = 'AccessControl.class_init:InitializeClass',
)
deprecated("import from AccessControl.Permission instead",
More information about the Zope-Checkins
mailing list