Skip to content

Commit

Permalink
Allow subclassing of TemplateDict
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Simpson committed Sep 4, 2001
1 parent 5578e54 commit 60065d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions DT_String.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
# 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
import thread,re,exceptions,os
Expand Down Expand Up @@ -486,7 +486,9 @@ def __call__(self,client=None,mapping={},**kw):

pushed=None
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

globals=self.globals
Expand Down
9 changes: 6 additions & 3 deletions DT_Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
'''$Id: DT_Util.py,v 1.82 2001/07/05 12:19:40 andreas Exp $'''
__version__='$Revision: 1.82 $'[11:-2]
'''$Id: DT_Util.py,v 1.83 2001/09/04 13:46:43 evan Exp $'''
__version__='$Revision: 1.83 $'[11:-2]

import re, os
from html_quote import html_quote # for import by other modules, dont remove!
Expand Down Expand Up @@ -145,6 +145,7 @@ def __init__(self, f):
_marker = [] # Create a new marker object.

def careful_getattr(md, inst, name, default=_marker):

get = md.guarded_getattr
if get is None:
get = getattr
Expand All @@ -156,6 +157,7 @@ def careful_getattr(md, inst, name, default=_marker):
return default

def careful_hasattr(md, inst, name):

get = md.guarded_getattr
if get is None:
get = getattr
Expand All @@ -172,7 +174,8 @@ def careful_hasattr(md, inst, name):
def namespace(self, **kw):
"""Create a tuple consisting of a single instance whose attributes are
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
incorrect "self" argument. It could be caused by a product which
is not yet compatible with this version of Zope. The traceback
Expand Down

0 comments on commit 60065d4

Please sign in to comment.