Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a3a1e991
Commit
a3a1e991
authored
May 16, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move InitializeClass into AccessControl
parent
b9148a26
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
106 additions
and
88 deletions
+106
-88
src/AccessControl/Owned.py
src/AccessControl/Owned.py
+1
-1
src/AccessControl/PermissionMapping.py
src/AccessControl/PermissionMapping.py
+1
-1
src/AccessControl/Role.py
src/AccessControl/Role.py
+1
-1
src/AccessControl/SecurityInfo.py
src/AccessControl/SecurityInfo.py
+1
-1
src/AccessControl/User.py
src/AccessControl/User.py
+1
-1
src/AccessControl/class_init.py
src/AccessControl/class_init.py
+89
-0
src/AccessControl/metaconfigure.py
src/AccessControl/metaconfigure.py
+1
-1
src/AccessControl/securitySuite/regressionSecurity.py
src/AccessControl/securitySuite/regressionSecurity.py
+1
-2
src/AccessControl/tests/testAcquisition.py
src/AccessControl/tests/testAcquisition.py
+1
-1
src/AccessControl/tests/testBindings.py
src/AccessControl/tests/testBindings.py
+1
-1
src/AccessControl/tests/testClassSecurityInfo.py
src/AccessControl/tests/testClassSecurityInfo.py
+1
-1
src/AccessControl/tests/testZCML.py
src/AccessControl/tests/testZCML.py
+1
-1
src/AccessControl/tests/testZopeGuards.py
src/AccessControl/tests/testZopeGuards.py
+1
-1
src/App/class_init.py
src/App/class_init.py
+3
-73
src/Globals/__init__.py
src/Globals/__init__.py
+2
-2
No files found.
src/AccessControl/Owned.py
View file @
a3a1e991
...
...
@@ -21,10 +21,10 @@ from Acquisition import aq_get
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
...
...
src/AccessControl/PermissionMapping.py
View file @
a3a1e991
...
...
@@ -22,10 +22,10 @@ $Id$
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
...
...
src/AccessControl/Role.py
View file @
a3a1e991
...
...
@@ -22,13 +22,13 @@ from Acquisition import aq_get
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
...
...
src/AccessControl/SecurityInfo.py
View file @
a3a1e991
...
...
@@ -311,5 +311,5 @@ def allow_class(Class):
sec
.
declareObjectPublic
()
sec
.
setDefaultAccess
(
1
)
sec
.
apply
(
Class
)
from
A
pp
.class_init
import
InitializeClass
from
A
ccessControl
.class_init
import
InitializeClass
InitializeClass
(
Class
)
src/AccessControl/User.py
View file @
a3a1e991
...
...
@@ -24,12 +24,12 @@ from Acquisition import aq_base
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
...
...
src/AccessControl/class_init.py
0 → 100644
View file @
a3a1e991
##############################################################################
#
# 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
src/AccessControl/metaconfigure.py
View file @
a3a1e991
...
...
@@ -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
):
...
...
src/AccessControl/securitySuite/regressionSecurity.py
View file @
a3a1e991
...
...
@@ -15,14 +15,13 @@
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
...
...
src/AccessControl/tests/testAcquisition.py
View file @
a3a1e991
...
...
@@ -25,8 +25,8 @@ import Zope2
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
...
...
src/AccessControl/tests/testBindings.py
View file @
a3a1e991
...
...
@@ -21,7 +21,7 @@ import ZODB
import
transaction
from
Acquisition
import
Implicit
from
AccessControl
import
ClassSecurityInfo
from
A
pp
.class_init
import
InitializeClass
from
A
ccessControl
.class_init
import
InitializeClass
from
OFS.ObjectManager
import
ObjectManager
from
OFS.Folder
import
Folder
...
...
src/AccessControl/tests/testClassSecurityInfo.py
View file @
a3a1e991
...
...
@@ -28,7 +28,7 @@ class ClassSecurityInfoTests(unittest.TestCase):
# Test setting default roles for permissions.
from
A
pp
.class_init
import
InitializeClass
from
A
ccessControl
.class_init
import
InitializeClass
from
ExtensionClass
import
Base
ClassSecurityInfo
=
self
.
_getTargetClass
()
...
...
src/AccessControl/tests/testZCML.py
View file @
a3a1e991
...
...
@@ -109,7 +109,7 @@ def test_security_equivalence():
>>> from zope.configuration.xmlconfig import xmlconfig
>>> xmlconfig(configure_zcml)
>>> from A
pp
.class_init import InitializeClass
>>> from A
ccessControl
.class_init import InitializeClass
>>> InitializeClass(Dummy2)
Now we compare their access controls:
...
...
src/AccessControl/tests/testZopeGuards.py
View file @
a3a1e991
...
...
@@ -583,9 +583,9 @@ class TestActualPython(GuardTestCase):
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
:
...
...
src/App/class_init.py
View file @
a3a1e991
...
...
@@ -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
src/Globals/__init__.py
View file @
a3a1e991
...
...
@@ -34,8 +34,8 @@ deprecated("import from Persistence instead",
PersistentMapping
=
'Persistence:PersistentMapping'
,
)
deprecated
(
"import from A
pp
.class_init instead"
,
InitializeClass
=
'A
pp
.class_init:InitializeClass'
,
deprecated
(
"import from A
ccessControl
.class_init instead"
,
InitializeClass
=
'A
ccessControl
.class_init:InitializeClass'
,
)
deprecated
(
"import from AccessControl.Permission instead"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment