[Checkins] SVN: zope.component/branches/tlotze-hooks/src/zope/component/hooks.py use zope.security only if available
Thomas Lotze
tl at gocept.com
Wed Oct 21 11:18:00 EDT 2009
Log message for revision 105192:
use zope.security only if available
Changed:
U zope.component/branches/tlotze-hooks/src/zope/component/hooks.py
-=-
Modified: zope.component/branches/tlotze-hooks/src/zope/component/hooks.py
===================================================================
--- zope.component/branches/tlotze-hooks/src/zope/component/hooks.py 2009-10-21 12:50:04 UTC (rev 105191)
+++ zope.component/branches/tlotze-hooks/src/zope/component/hooks.py 2009-10-21 15:17:59 UTC (rev 105192)
@@ -19,8 +19,15 @@
import threading
import zope.component
-import zope.security
+try:
+ import zope.security.proxy
+except ImportError:
+ SECURITY_SUPPORT = False
+else:
+ SECURITY_SUPPORT = True
+
+
class read_property(object):
def __init__(self, func):
self.func = func
@@ -56,7 +63,9 @@
# once site managers do less. There's probably no good reason why
# they can't be proxied. Well, except maybe for performance.
- site = zope.security.proxy.removeSecurityProxy(site)
+ if SECURITY_SUPPORT:
+ site = zope.security.proxy.removeSecurityProxy(site)
+ # The getSiteManager method is defined by IPossibleSite.
sm = site.getSiteManager()
siteinfo.site = site
@@ -87,7 +96,9 @@
# they can't be proxied. Well, except maybe for performance.
sm = zope.component.interfaces.IComponentLookup(
context, zope.component.getGlobalSiteManager())
- return zope.security.proxy.removeSecurityProxy(sm)
+ if SECURITY_SUPPORT:
+ sm = zope.security.proxy.removeSecurityProxy(sm)
+ return sm
def adapter_hook(interface, object, name='', default=None):
More information about the checkins
mailing list