[Zope-Checkins] SVN: Zope/trunk/lib/python/ Got rid of import order
dependencies in PageTemplates, TAL, and ZTUtils.
Stefan H. Holek
stefan at epy.co.at
Thu Jan 27 09:56:22 EST 2005
Log message for revision 28963:
Got rid of import order dependencies in PageTemplates, TAL, and ZTUtils.
Changed:
U Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
U Zope/trunk/lib/python/TAL/DummyEngine.py
U Zope/trunk/lib/python/ZTUtils/__init__.py
-=-
Modified: Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2005-01-27 11:39:48 UTC (rev 28962)
+++ Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2005-01-27 14:56:22 UTC (rev 28963)
@@ -44,43 +44,14 @@
reg('not', NotExpr)
reg('defer', DeferExpr)
-if sys.modules.has_key('Zope'):
- import AccessControl
- import AccessControl.cAccessControl
- acquisition_security_filter = AccessControl.cAccessControl.aq_validate
- from AccessControl import getSecurityManager
- from AccessControl.ZopeGuards import guarded_getattr
- try:
- from AccessControl import Unauthorized
- except ImportError:
- Unauthorized = "Unauthorized"
- from ZRPythonExpr import PythonExpr, _SecureModuleImporter, call_with_ns
-else:
- from PythonExpr import getSecurityManager, PythonExpr
- guarded_getattr = getattr
- try:
- from zExceptions import Unauthorized
- except ImportError:
- Unauthorized = "Unauthorized"
+import AccessControl
+import AccessControl.cAccessControl
+acquisition_security_filter = AccessControl.cAccessControl.aq_validate
+from AccessControl import getSecurityManager
+from AccessControl.ZopeGuards import guarded_getattr
+from AccessControl import Unauthorized
+from ZRPythonExpr import PythonExpr, _SecureModuleImporter, call_with_ns
- def acquisition_security_filter(orig, inst, name, v, real_validate):
- if real_validate(orig, inst, name, v):
- return 1
- raise Unauthorized, name
-
- def call_with_ns(f, ns, arg=1):
- if arg==2:
- return f(None, ns)
- else:
- return f(ns)
-
- class _SecureModuleImporter:
- """Simple version of the importer for use with trusted code."""
- __allow_access_to_unprotected_subobjects__ = 1
- def __getitem__(self, module):
- __import__(module)
- return sys.modules[module]
-
SecureModuleImporter = _SecureModuleImporter()
Undefs = (Undefined, AttributeError, KeyError,
Modified: Zope/trunk/lib/python/TAL/DummyEngine.py
===================================================================
--- Zope/trunk/lib/python/TAL/DummyEngine.py 2005-01-27 11:39:48 UTC (rev 28962)
+++ Zope/trunk/lib/python/TAL/DummyEngine.py 2005-01-27 14:56:22 UTC (rev 28963)
@@ -23,12 +23,11 @@
from DocumentTemplate.DT_Util import ustr
IDomain = None
-if sys.modules.has_key('Zope'):
- try:
- from Zope.I18n.ITranslationService import ITranslationService
- from Zope.I18n.IDomain import IDomain
- except ImportError:
- pass
+try:
+ from Zope.I18n.ITranslationService import ITranslationService
+ from Zope.I18n.IDomain import IDomain
+except ImportError:
+ pass
if IDomain is None:
# Before 2.7, or not in Zope
class ITranslationService: pass
Modified: Zope/trunk/lib/python/ZTUtils/__init__.py
===================================================================
--- Zope/trunk/lib/python/ZTUtils/__init__.py 2005-01-27 11:39:48 UTC (rev 28962)
+++ Zope/trunk/lib/python/ZTUtils/__init__.py 2005-01-27 14:56:22 UTC (rev 28963)
@@ -15,16 +15,12 @@
$Id$
"""
-from Batch import Batch
from Iterator import Iterator
-from Tree import TreeMaker, encodeExpansion, decodeExpansion, a2b, b2a
+from Tree import encodeExpansion, decodeExpansion, a2b, b2a
from SimpleTree import SimpleTreeMaker
-import sys
-if sys.modules.has_key('Zope'):
- del sys
- __allow_access_to_unprotected_subobjects__ = 1
- __roles__ = None
+__allow_access_to_unprotected_subobjects__ = 1
+__roles__ = None
- from Zope import Batch, TreeMaker, SimpleTreeMaker, LazyFilter
- from Zope import url_query, make_query, make_hidden_input
+from ZTUtils.Zope import Batch, TreeMaker, SimpleTreeMaker, LazyFilter
+from ZTUtils.Zope import url_query, make_query, make_hidden_input
More information about the Zope-Checkins
mailing list