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
a6aacea8
Commit
a6aacea8
authored
Feb 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge changes from 2.3 branch
parent
a04bce98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
lib/python/Products/PythonScripts/Utility.py
lib/python/Products/PythonScripts/Utility.py
+18
-12
No files found.
lib/python/Products/PythonScripts/Utility.py
View file @
a6aacea8
...
...
@@ -85,23 +85,29 @@
"""Utility module for making simple security assertions for
Python scripts."""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
from
AccessControl
import
ModuleSecurityInfo
from
AccessControl
import
ModuleSecurityInfo
,
ClassSecurityInfo
from
Globals
import
InitializeClass
import
string
def
allow_module
(
module_name
):
"""Allow a module and all its contents to be used from a
Python s
cript. The argument module_name may be a simple
restricted S
cript. The argument module_name may be a simple
or dotted module or package name. Note that if a package
path is given, all modules in the path will be available."""
module
=
__import__
(
module_name
)
sec_info
=
ModuleSecurityInfo
(
module
)
sec_info
.
setDefaultAccess
(
1
)
sec_info
.
apply
(
module
.
__dict__
)
for
part
in
string
.
split
(
module_name
,
'.'
)[
1
:]:
module
=
getattr
(
module
,
part
)
sec_info
=
ModuleSecurityInfo
(
module
)
sec_info
.
setDefaultAccess
(
1
)
sec_info
.
apply
(
module
.
__dict__
)
ModuleSecurityInfo
(
module_name
).
setDefaultAccess
(
1
)
dot
=
string
.
find
(
module_name
,
'.'
)
while
dot
>
0
:
ModuleSecurityInfo
(
module_name
[:
dot
]).
setDefaultAccess
(
1
)
dot
=
string
.
find
(
module_name
,
'.'
,
dot
+
1
)
def
allow_class
(
Class
):
"""Allow a class and all of its methods to be used from a
restricted Script. The argument Class must be a class."""
Class
.
_security
=
sec
=
ClassSecurityInfo
()
sec
.
declareObjectPublic
()
sec
.
setDefaultAccess
(
1
)
sec
.
apply
(
Class
)
InitializeClass
(
Class
)
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