Commit a6aacea8 authored by Evan Simpson's avatar Evan Simpson

Merge changes from 2.3 branch

parent a04bce98
......@@ -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 script. The argument module_name may be a simple
restricted Script. 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment