[Zope-Checkins] CVS: Zope/lib/python/AccessControl - SecurityInfo.py:1.15.6.1
Martijn Pieters
mj@zope.com
Thu, 21 Nov 2002 12:43:39 -0500
Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv21297/lib/python/AccessControl
Modified Files:
Tag: Zope-2_6-branch
SecurityInfo.py
Log Message:
Merge bugfix from trunk: Allow ModuleSecurityInfo objects to be reused even
after they have been applied to their modules.
=== Zope/lib/python/AccessControl/SecurityInfo.py 1.15 => 1.15.6.1 ===
--- Zope/lib/python/AccessControl/SecurityInfo.py:1.15 Wed Aug 14 17:29:07 2002
+++ Zope/lib/python/AccessControl/SecurityInfo.py Thu Nov 21 12:43:39 2002
@@ -198,6 +198,7 @@
access = 0
_moduleSecurity = {}
+_appliedModuleSecurity = {}
def secureModule(mname, *imp):
modsec = _moduleSecurity.get(mname, None)
@@ -209,12 +210,24 @@
apply(__import__, (mname,) + tuple(imp))
module = sys.modules[mname]
modsec.apply(module.__dict__)
+ _appliedModuleSecurity[mname] = modsec
return module
def ModuleSecurityInfo(module_name=None):
if module_name is not None:
modsec = _moduleSecurity.get(module_name, None)
if modsec is not None:
+ return modsec
+ modsec = _appliedModuleSecurity.get(module_name, None)
+ if modsec is not None:
+ # Move security info back to to-apply dict (needed for product
+ # refresh). Also invoke this check for parent packages already
+ # applied
+ del _appliedModuleSecurity[module_name]
+ _moduleSecurity[module_name] = modsec
+ dot = module_name.rfind('.')
+ if dot > 0:
+ ModuleSecurityInfo(module_name[:dot])
return modsec
dot = module_name.rfind('.')
if dot > 0: