[Zope-CVS] CVS: Products/VerboseSecurity -
PermissionRolePatch.py:1.3
Shane Hathaway
shane at zope.com
Tue Feb 3 15:35:42 EST 2004
Update of /cvs-repository/Products/VerboseSecurity
In directory cvs.zope.org:/tmp/cvs-serv10725
Modified Files:
PermissionRolePatch.py
Log Message:
Made the PermissionRole patch compatible with Zope 2.7.
=== Products/VerboseSecurity/PermissionRolePatch.py 1.2 => 1.3 ===
--- Products/VerboseSecurity/PermissionRolePatch.py:1.2 Thu Aug 22 12:50:05 2002
+++ Products/VerboseSecurity/PermissionRolePatch.py Tue Feb 3 15:35:41 2004
@@ -26,10 +26,14 @@
if 1:
- if imPermissionRole.__module__ == 'AccessControl.PermissionRole':
+ if imPermissionRole.__module__ in (
+ 'AccessControl.PermissionRole', # Before Zope 2.7
+ 'AccessControl.ImplPython', # Zope 2.7
+ ):
# Patch only the Python implementation
+ from types import StringType, UnicodeType
- def __of__(self, parent,tt=type(()),st=type(''),getattr=getattr):
+ def __of__(self, parent):
obj=parent
n=self._p
# The next line includes the permission name
@@ -43,12 +47,12 @@
t=type(roles)
- if t is tt:
+ if t is type(()):
# If we get a tuple, then we don't acquire
if r is None: return roles
return r+list(roles)
- if t is st:
+ if issubclass(t, StringType) or issubclass(t, UnicodeType):
# We found roles set to a name. Start over
# with the new permission name. If the permission
# name is '', then treat as private!
@@ -79,7 +83,11 @@
else:
from zLOG import LOG, INFO
+ from App.version_txt import getZopeVersion
+ pre_2_7 = (tuple(getZopeVersion()[:2]) < (2, 7))
+ if pre_2_7:
+ msg = "put ZOPE_SECURITY_POLICY=PYTHON in the environment."
+ else:
+ msg = "add 'security-policy-implementation python' to zope.conf."
LOG('VerboseSecurity', INFO, "Unable to patch PermissionRole. "
- "Put ZOPE_SECURITY_POLICY=PYTHON in the environment to "
- "enable display of permission names in Unauthorized exceptions.")
-
+ "To see permission names in Unauthorized exceptions, " + msg)
More information about the Zope-CVS
mailing list