summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Korostelev <nadako@gmail.com>2009-03-09 16:10:49 +0000
committerDan Korostelev <nadako@gmail.com>2009-03-09 16:10:49 +0000
commitf2185764ca99164e4bf9cf4d087f385063df0a59 (patch)
treea0f8f41515d9466d78757aaaf61fa07f04de9952
parent693b1e24226324c73f1168a2234b60d673727e66 (diff)
downloadzope-security-f2185764ca99164e4bf9cf4d087f385063df0a59.tar.gz
Change use of zope.deferredimport to from imports.
-rw-r--r--CHANGES.txt3
-rw-r--r--setup.py1
-rw-r--r--src/zope/security/__init__.py10
-rw-r--r--src/zope/security/_definitions.py7
-rw-r--r--src/zope/security/decorator.py17
-rw-r--r--src/zope/security/management.py11
-rw-r--r--src/zope/security/proxy.py2
7 files changed, 18 insertions, 33 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index fba1689..3fc5035 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,9 @@ CHANGES
3.6.1 (unreleased)
------------------
+- Use ``from`` imports instead of ``zope.deferred`` to avoid circular
+ import problems, thus drop dependency on ``zope.deferredimport``.
+
- Raise NoInteraction when zope.security.checkPermission is called
without interaction being active (LP #301565).
diff --git a/setup.py b/setup.py
index d4d832d..8e16d2c 100644
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,6 @@ setup(name='zope.security',
'pytz',
'zope.component',
'zope.configuration',
- 'zope.deferredimport',
'zope.exceptions',
'zope.i18nmessageid',
'zope.interface',
diff --git a/src/zope/security/__init__.py b/src/zope/security/__init__.py
index 18360ed..111006d 100644
--- a/src/zope/security/__init__.py
+++ b/src/zope/security/__init__.py
@@ -16,11 +16,5 @@
$Id$
"""
-
-import zope.deferredimport
-
-zope.deferredimport.define(
- checkPermission = 'zope.security.management:checkPermission',
- canWrite = 'zope.security.checker:canWrite',
- canAccess = 'zope.security.checker:canAccess',
- )
+from zope.security.management import checkPermission
+from zope.security.checker import canWrite, canAccess
diff --git a/src/zope/security/_definitions.py b/src/zope/security/_definitions.py
index 09a6a84..ff2aa8e 100644
--- a/src/zope/security/_definitions.py
+++ b/src/zope/security/_definitions.py
@@ -13,17 +13,14 @@
##############################################################################
"""Common definitions to avoid circular imports
"""
-
import threading
-
import zope.interface
-
-import zope.security.interfaces
+from zope.security import interfaces
thread_local = threading.local()
class system_user(object):
- zope.interface.classProvides(zope.security.interfaces.IPrincipal)
+ zope.interface.classProvides(interfaces.IPrincipal)
id = u'zope.security.management.system_user'
title = u'System'
description = u''
diff --git a/src/zope/security/decorator.py b/src/zope/security/decorator.py
index 28ce913..bcdf289 100644
--- a/src/zope/security/decorator.py
+++ b/src/zope/security/decorator.py
@@ -20,19 +20,12 @@ $Id$
"""
__docformat__ = "reStructuredText"
+from zope.interface.declarations import ObjectSpecification
from zope.proxy import getProxiedObject, ProxyBase
from zope.proxy.decorator import SpecificationDecoratorBase
from zope.security.checker import selectChecker, CombinedChecker
-from zope.interface.declarations import ObjectSpecification
-import zope.deferredimport
-
-# zope.security.proxy depends on this module because of the re-injection of
-# security compatibility with zope.location. To avoid circular import problems
-# and as those two symbols are only needed at run-time, not module-execution
-# time, we import them deferred.
-zope.deferredimport.define(
- Proxy='zope.security.proxy:Proxy',
- getChecker='zope.security.proxy:getChecker')
+from zope.security.proxy import Proxy
+from zope.security.proxy import getChecker
class DecoratedSecurityCheckerDescriptor(object):
@@ -176,8 +169,8 @@ class DecoratedSecurityCheckerDescriptor(object):
return self
else:
proxied_object = getProxiedObject(inst)
- if type(proxied_object) is zope.security.decorator.Proxy:
- checker = zope.security.decorator.getChecker(proxied_object)
+ if type(proxied_object) is Proxy:
+ checker = getChecker(proxied_object)
else:
checker = getattr(proxied_object, '__Security_checker__', None)
if checker is None:
diff --git a/src/zope/security/management.py b/src/zope/security/management.py
index dbe8381..0d509c0 100644
--- a/src/zope/security/management.py
+++ b/src/zope/security/management.py
@@ -19,8 +19,7 @@ $Id$
import zope.interface
-import zope.security.interfaces
-
+from zope.security import interfaces
from zope.security.checker import CheckerPublic
from zope.security._definitions import thread_local, system_user
from zope.security.simplepolicies import ParanoidSecurityPolicy
@@ -28,8 +27,8 @@ from zope.security.simplepolicies import ParanoidSecurityPolicy
_defaultPolicy = ParanoidSecurityPolicy
zope.interface.moduleProvides(
- zope.security.interfaces.ISecurityManagement,
- zope.security.interfaces.IInteractionManagement)
+ interfaces.ISecurityManagement,
+ interfaces.IInteractionManagement)
def _clear():
global _defaultPolicy
@@ -81,7 +80,7 @@ def getInteraction():
try:
return thread_local.interaction
except AttributeError:
- raise zope.security.interfaces.NoInteraction
+ raise interfaces.NoInteraction
def newInteraction(*participations):
"""Start a new interaction."""
@@ -140,7 +139,7 @@ def checkPermission(permission, object, interaction=None):
try:
interaction = thread_local.interaction
except AttributeError:
- raise zope.security.interfaces.NoInteraction
+ raise interfaces.NoInteraction
return interaction.checkPermission(permission, object)
addCleanUp(endInteraction)
diff --git a/src/zope/security/proxy.py b/src/zope/security/proxy.py
index 5b08caa..5760edf 100644
--- a/src/zope/security/proxy.py
+++ b/src/zope/security/proxy.py
@@ -18,7 +18,6 @@ $Id$
__docformat__ = 'restructuredtext'
import zope.location.location
-from zope.security.decorator import DecoratedSecurityCheckerDescriptor
from zope.security._proxy import getChecker, getObject
from zope.security._proxy import _Proxy as Proxy
@@ -80,5 +79,6 @@ def isinstance(object, cls):
# location proxy from here.
# This is the only sane place we found for doing it: it kicks in as soon
# as someone starts using security proxies.
+from zope.security.decorator import DecoratedSecurityCheckerDescriptor
zope.location.location.LocationProxy.__Security_checker__ = (
DecoratedSecurityCheckerDescriptor())