[Zope-Checkins] CVS: Releases/Zope/lib/python/Products/PythonScripts - Utility.py:1.5 module_access_examples.py:1.2

Evan Simpson evan@zope.com
Fri, 11 Jan 2002 12:14:30 -0500


Update of /cvs-repository/Releases/Zope/lib/python/Products/PythonScripts
In directory cvs.zope.org:/tmp/cvs-serv29374/Products/PythonScripts

Modified Files:
	Utility.py module_access_examples.py 
Log Message:
Merge evan-modsec_fix-branch


=== Releases/Zope/lib/python/Products/PythonScripts/Utility.py 1.4 => 1.5 ===
 __version__='$Revision$'[11:-2]
 
-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
-    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."""
-    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)
+# These have been relocated, and should be imported from AccessControl
 
+from AccessControl import allow_module, allow_class


=== Releases/Zope/lib/python/Products/PythonScripts/module_access_examples.py 1.1 => 1.2 ===
 '''
 
-from Products.PythonScripts.Utility import allow_module, allow_class
+from AccessControl import allow_module, allow_class, allow_type
 from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
 from Globals import InitializeClass
 
@@ -42,9 +42,9 @@
 # ModuleSecurityInfo('re').declarePublic('compile', 'findall',
 #   'match', 'search', 'split', 'sub', 'subn', 'error',
 #   'I', 'L', 'M', 'S', 'X')
-# from re import RegexObject, MatchObject
-# allow_class(RegexObject)
-# allow_class(MatchObject)
+# import re
+# allow_type(type(re.compile('')))
+# allow_type(type(re.match('x','x')))
 
 # ModuleSecurityInfo('StringIO').declarePublic('StringIO')