[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/pagetemplate/engine.py - remove crufty use of the types module

Fred L. Drake, Jr. fred at zope.com
Tue Jul 20 15:33:33 EDT 2004


Log message for revision 26639:
  - remove crufty use of the types module
  - add a comment explaining why this implementation of path:modules/
    makes sense and is appropriate
  


Changed:
  U   Zope3/trunk/src/zope/app/pagetemplate/engine.py


-=-
Modified: Zope3/trunk/src/zope/app/pagetemplate/engine.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/engine.py	2004-07-20 19:17:28 UTC (rev 26638)
+++ Zope3/trunk/src/zope/app/pagetemplate/engine.py	2004-07-20 19:33:33 UTC (rev 26639)
@@ -18,7 +18,6 @@
 $Id$
 """
 import sys
-from types import StringTypes
 
 from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr
 from zope.tales.pythonexpr import PythonExpr
@@ -68,7 +67,7 @@
         text = self.evaluate(expr)
         if text is self.getDefault() or text is None:
             return text
-        if isinstance(text, StringTypes):
+        if isinstance(text, basestring):
             # text could be a proxied/wrapped object
             return text
         return unicode(text)
@@ -197,7 +196,13 @@
     engine.registerType('python', ZopePythonExpr)
     engine.registerType('not', NotExpr)
     engine.registerType('defer', DeferExpr)
+
+    # Using a proxy around sys.modules allows page templates to use
+    # modules for which security declarations have been made, but
+    # disallows execution of any import-time code for modules, which
+    # should not be allowed to happen during rendering.
     engine.registerBaseName('modules', ProxyFactory(sys.modules))
+
     return engine
 
 Engine = _Engine()



More information about the Zope3-Checkins mailing list