Commit 20164192 authored by Evan Simpson's avatar Evan Simpson

Allow subclassing of TemplateDict

parent a8759581
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
"$Id: DT_String.py,v 1.46 2001/06/21 17:45:12 shane Exp $" "$Id: DT_String.py,v 1.47 2001/09/04 13:46:43 evan Exp $"
from string import split, strip from string import split, strip
import thread,re,exceptions,os import thread,re,exceptions,os
...@@ -486,7 +486,9 @@ class String: ...@@ -486,7 +486,9 @@ class String:
pushed=None pushed=None
try: try:
if mapping.__class__ is TemplateDict: pushed=0 # Support Python 1.5.2, but work better in 2.1
if (mapping.__class__ is TemplateDict or
isinstance(mapping, TemplateDict)): pushed=0
except: pass except: pass
globals=self.globals globals=self.globals
......
...@@ -82,8 +82,8 @@ ...@@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
'''$Id: DT_Util.py,v 1.82 2001/07/05 12:19:40 andreas Exp $''' '''$Id: DT_Util.py,v 1.83 2001/09/04 13:46:43 evan Exp $'''
__version__='$Revision: 1.82 $'[11:-2] __version__='$Revision: 1.83 $'[11:-2]
import re, os import re, os
from html_quote import html_quote # for import by other modules, dont remove! from html_quote import html_quote # for import by other modules, dont remove!
...@@ -145,6 +145,7 @@ if LIMITED_BUILTINS: ...@@ -145,6 +145,7 @@ if LIMITED_BUILTINS:
_marker = [] # Create a new marker object. _marker = [] # Create a new marker object.
def careful_getattr(md, inst, name, default=_marker): def careful_getattr(md, inst, name, default=_marker):
get = md.guarded_getattr get = md.guarded_getattr
if get is None: if get is None:
get = getattr get = getattr
...@@ -156,6 +157,7 @@ def careful_getattr(md, inst, name, default=_marker): ...@@ -156,6 +157,7 @@ def careful_getattr(md, inst, name, default=_marker):
return default return default
def careful_hasattr(md, inst, name): def careful_hasattr(md, inst, name):
get = md.guarded_getattr get = md.guarded_getattr
if get is None: if get is None:
get = getattr get = getattr
...@@ -172,7 +174,8 @@ d['hasattr']=careful_hasattr ...@@ -172,7 +174,8 @@ d['hasattr']=careful_hasattr
def namespace(self, **kw): def namespace(self, **kw):
"""Create a tuple consisting of a single instance whose attributes are """Create a tuple consisting of a single instance whose attributes are
provided as keyword arguments.""" provided as keyword arguments."""
if getattr(self, '__class__', None) != TemplateDict: if not (getattr(self, '__class__', None) == TemplateDict or
isinstance(self, TemplateDict)):
raise TypeError,'''A call was made to DT_Util.namespace() with an raise TypeError,'''A call was made to DT_Util.namespace() with an
incorrect "self" argument. It could be caused by a product which incorrect "self" argument. It could be caused by a product which
is not yet compatible with this version of Zope. The traceback is not yet compatible with this version of Zope. The traceback
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment