[Zope-Checkins] CVS: Zope/lib/python/DocumentTemplate -
DT_Util.py:1.89.26.1
Jim Fulton
cvs-admin at zope.org
Sat Nov 15 07:12:09 EST 2003
Update of /cvs-repository/Zope/lib/python/DocumentTemplate
In directory cvs.zope.org:/tmp/cvs-serv24381/lib/python/DocumentTemplate
Modified Files:
Tag: zodb33-devel-branch
DT_Util.py
Log Message:
Changed class modification code to use setattr rather than class
dictionary manipulation, since new-style class dictionaries are
immutable
=== Zope/lib/python/DocumentTemplate/DT_Util.py 1.89 => 1.89.26.1 ===
--- Zope/lib/python/DocumentTemplate/DT_Util.py:1.89 Thu Feb 27 12:31:27 2003
+++ Zope/lib/python/DocumentTemplate/DT_Util.py Sat Nov 15 07:11:35 2003
@@ -42,8 +42,9 @@
import ExtensionClass
from cDocumentTemplate import InstanceDict, TemplateDict, \
render_blocks, safe_callable, join_unicode
-except: from pDocumentTemplate import InstanceDict, TemplateDict, \
- render_blocks, safe_callable, join_unicode
+except:
+ from pDocumentTemplate import InstanceDict, TemplateDict, \
+ render_blocks, safe_callable, join_unicode
functype = type(int_param)
class NotBindable:
@@ -51,21 +52,18 @@
def __init__(self, f):
self.__call__ = f
-d = TemplateDict.__dict__
for name, f in safe_builtins.items() + utility_builtins.items():
if type(f) is functype:
- d[name] = NotBindable(f)
- else:
- d[name] = f
+ f = NotBindable(f)
+ setattr(TemplateDict, name, f)
if LIMITED_BUILTINS:
# Replace certain builtins with limited versions.
from RestrictedPython.Limits import limited_builtins
for name, f in limited_builtins.items():
if type(f) is functype:
- d[name] = NotBindable(f)
- else:
- d[name] = f
+ f = NotBindable(f)
+ setattr(TemplateDict, name, f)
try:
# Wrap the string module so it can deal with TaintedString strings.
@@ -104,7 +102,7 @@
retval = TaintedString(retval)
return retval
- d['string'] = StringModuleWrapper()
+ TemplateDict.string = StringModuleWrapper()
except ImportError:
# Use the string module already defined in RestrictedPython.Utilities
@@ -138,8 +136,8 @@
else:
return 1
-d['getattr']=careful_getattr
-d['hasattr']=careful_hasattr
+TemplateDict.getattr = careful_getattr
+TemplateDict.hasattr = careful_hasattr
def namespace(self, **kw):
"""Create a tuple consisting of a single instance whose attributes are
@@ -152,7 +150,7 @@
information may contain more details.)'''
return self(**kw)
-d['namespace']=namespace
+TemplateDict.namespace = namespace
def render(self, v):
"Render an object in the way done by the 'name' attribute"
@@ -167,7 +165,7 @@
v = v()
return v
-d['render']=render
+TemplateDict.render = render
class Eval(RestrictionCapableEval):
More information about the Zope-Checkins
mailing list