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
b8153d8e
Commit
b8153d8e
authored
Jan 29, 2004
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix & document setImplementation semantics
parent
adacd32f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
14 deletions
+32
-14
lib/python/AccessControl/Implementation.py
lib/python/AccessControl/Implementation.py
+11
-3
lib/python/AccessControl/tests/testImplementation.py
lib/python/AccessControl/tests/testImplementation.py
+21
-11
No files found.
lib/python/AccessControl/Implementation.py
View file @
b8153d8e
...
@@ -31,12 +31,18 @@ def getImplementationName():
...
@@ -31,12 +31,18 @@ def getImplementationName():
def
setImplementation
(
name
):
def
setImplementation
(
name
):
"""Select the policy implementation to use.
"""Select the policy implementation to use. The 'name' must be either
'PYTHON' or 'C'. NOTE: this function is intended to be called
'name' must be either 'PYTHON' or 'C'.
exactly once, so that the Zope config file can dictate the policy
implementation to be used. Subsequent calls to this function will
have no effect!!
"""
"""
import
sys
import
sys
global
_implementation_name
global
_implementation_name
global
_implementation_set
if
_implementation_set
:
return
name
=
name
.
upper
()
name
=
name
.
upper
()
if
name
==
_implementation_name
:
if
name
==
_implementation_name
:
...
@@ -57,8 +63,10 @@ def setImplementation(name):
...
@@ -57,8 +63,10 @@ def setImplementation(name):
if
hasattr
(
mod
,
"initialize"
):
if
hasattr
(
mod
,
"initialize"
):
mod
.
initialize
(
impl
)
mod
.
initialize
(
impl
)
_implementation_set
=
1
_implementation_name
=
None
_implementation_name
=
None
_implementation_set
=
0
_policy_names
=
{
_policy_names
=
{
"AccessControl"
:
(
"setDefaultBehaviors"
,
"AccessControl"
:
(
"setDefaultBehaviors"
,
...
...
lib/python/AccessControl/tests/testImplementation.py
View file @
b8153d8e
...
@@ -37,17 +37,27 @@ class AccessControlImplementationTest(unittest.TestCase):
...
@@ -37,17 +37,27 @@ class AccessControlImplementationTest(unittest.TestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
setImplementation
(
self
.
original
)
setImplementation
(
self
.
original
)
def
test_setImplemenationC
(
self
):
## Note - this test is disabled because the intent for 2.7 was *not*
setImplementation
(
"C"
)
## to support the ability to arbitrarily switch the security policy
name
=
getImplementationName
()
## at any time (which would currently be nearly impossible to do in
if
self
.
have_cAccessControl
:
## a way that would be sane for 3rd party apps that may already have
self
.
assertEqual
(
name
,
"C"
)
## imported parts of the security machinery), but just to make sure
else
:
## that the config file could be used to initially set the implementation
self
.
assertEqual
(
name
,
"PYTHON"
)
## to be used. The policy setting is 'initialize once' - setImplementation
## should not be called either by user code or unit tests, as the
def
test_setImplemenationPython
(
self
):
## effects are officially undefined.
setImplementation
(
"Python"
)
self
.
assertEqual
(
getImplementationName
(),
"PYTHON"
)
## def test_setImplemenationC(self):
## setImplementation("C")
## name = getImplementationName()
## if self.have_cAccessControl:
## self.assertEqual(name, "C")
## else:
## self.assertEqual(name, "PYTHON")
## def test_setImplemenationPython(self):
## setImplementation("Python")
## self.assertEqual(getImplementationName(), "PYTHON")
def
test_suite
():
def
test_suite
():
...
...
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