diff options
author | tavis_rudd <tavis_rudd> | 2001-08-03 19:20:50 +0000 |
---|---|---|
committer | tavis_rudd <tavis_rudd> | 2001-08-03 19:20:50 +0000 |
commit | f7eee3bd60ee808b3535952e9aef51c714c48f28 (patch) | |
tree | a7a6402930777a8a9371ae4adc9a73143cbfbf93 | |
parent | 700c7729bbe0871c437033360f8968acf3e9face (diff) | |
download | python-cheetah-f7eee3bd60ee808b3535952e9aef51c714c48f28.tar.gz |
made changes to Template.py, CodeGenerator.py, PlaceholderProcessor.py,
and TagProcessor.py to enable customization of the placeholderStartToken
(default $).
+ updated so docs
-rw-r--r-- | examples/webware_examples/cheetahSite/SiteTemplate.tmpl | 10 | ||||
-rwxr-xr-x | setup.py | 12 | ||||
-rw-r--r-- | src/CodeGenerator.py | 46 | ||||
-rw-r--r-- | src/NameMapper.py | 14 | ||||
-rw-r--r-- | src/PlaceholderProcessor.py | 85 | ||||
-rw-r--r-- | src/Servlet.py | 22 | ||||
-rw-r--r-- | src/TagProcessor.py | 16 | ||||
-rw-r--r-- | src/Template.py | 17 |
8 files changed, 143 insertions, 79 deletions
diff --git a/examples/webware_examples/cheetahSite/SiteTemplate.tmpl b/examples/webware_examples/cheetahSite/SiteTemplate.tmpl index 94569ef..448ec94 100644 --- a/examples/webware_examples/cheetahSite/SiteTemplate.tmpl +++ b/examples/webware_examples/cheetahSite/SiteTemplate.tmpl @@ -13,19 +13,19 @@ #end macro #macro insetBox(width=170, boxTitle='', boxContents='') -<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=$width> +<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=$*width> <TR> <TD COLSPAN=3 HEIGHT=1 BGCOLOR="$*insetBoxes.titleFrameColor">#spacer()</TD> </TR> <TR> <TD WIDTH=1 BGCOLOR="$*insetBoxes.titleFrameColor">#spacer()</TD> - <TD WIDTH=900 HEIGHT=1 BGCOLOR="$mainTbl.outerFrameColor">#spacer()</TD> ## force full width + <TD WIDTH=900 HEIGHT=1 BGCOLOR="$*mainTbl.outerFrameColor">#spacer()</TD> ## force full width <TD WIDTH=1 BGCOLOR="$*insetBoxes.titleFrameColor">#spacer()</TD> </TR> <TR> <TD WIDTH=1 BGCOLOR="$*insetBoxes.titleFrameColor">#spacer()</TD> - <TD WIDTH=900 HEIGHT=1 BGCOLOR="$mainTbl.innerFrameColor"> ## force full width - <DIV CLASS="insetBoxTitleContainer"><DIV CLASS="insetBoxTitle">$boxTitle</DIV></DIV> + <TD WIDTH=900 HEIGHT=1 BGCOLOR="$*mainTbl.innerFrameColor"> ## force full width + <DIV CLASS="insetBoxTitleContainer"><DIV CLASS="insetBoxTitle">$*boxTitle</DIV></DIV> </TD> <TD WIDTH=1 BGCOLOR="$*insetBoxes.titleFrameColor">#spacer()</TD> </TR> @@ -51,7 +51,7 @@ </TR> </TABLE> -<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=$width> +<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=$*width> <TR> <TD HEIGHT=1 BGCOLOR="$*insetBoxes.frameColor">#spacer()</TD> </TR> @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: setup.py,v 1.5 2001/08/02 05:17:15 tavis_rudd Exp $ +# $Id: setup.py,v 1.6 2001/08/03 19:20:50 tavis_rudd Exp $ """A setup module for the Cheetah package, based on the disutils module Meta-Data @@ -7,18 +7,18 @@ Meta-Data Author: Tavis Rudd <tavis@calrudd.com> License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.5 $ +Version: $Revision: 1.6 $ Start Date: 2001/03/30 -Last Revision Date: $Date: 2001/08/02 05:17:15 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.5 $"[11:-2] +__version__ = "$Revision: 1.6 $"[11:-2] ################################################## ## DEPENDENCIES ## -from distutils.core import setup +from distutils.core import setup, Extension from distutils.command.sdist import sdist import os @@ -94,6 +94,8 @@ if __name__ == '__main__': packages = packages, package_dir = {'Cheetah':'src'}, + #ext_modules=[Extension("Cheetah/_namemapper", ["src/_namemapper.c"])], + scripts = ['bin/cheetah-compile',], cmdclass = { 'sdist_docs' : sdist_docs }, diff --git a/src/CodeGenerator.py b/src/CodeGenerator.py index 6cc072d..5bafe53 100644 --- a/src/CodeGenerator.py +++ b/src/CodeGenerator.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: CodeGenerator.py,v 1.15 2001/08/02 19:50:11 tavis_rudd Exp $ +# $Id: CodeGenerator.py,v 1.16 2001/08/03 19:20:50 tavis_rudd Exp $ """Utilities, processors and filters for Cheetah's codeGenerator Cheetah's codeGenerator is designed to be extensible with plugin @@ -10,12 +10,12 @@ Meta-Data Author: Tavis Rudd <tavis@calrudd.com> License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.15 $ +Version: $Revision: 1.16 $ Start Date: 2001/03/30 -Last Revision Date: $Date: 2001/08/02 19:50:11 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.15 $"[11:-2] +__version__ = "$Revision: 1.16 $"[11:-2] ################################################## ## DEPENDENCIES ## @@ -93,7 +93,8 @@ class DisplayLogicProcessor(TagProcessor.TagProcessor): if tag[0:3] == 'for': ##translate this #for $i in $list/# to this #for i in $list/# INkeywordPos = tag.find(' in ') - tag = tag[0:INkeywordPos].replace('$','') + \ + tag = tag[0:INkeywordPos].replace( + templateObj.setting('placeholderStartToken'),'') + \ tag[INkeywordPos:] ## register the local vars in the loop with the templateObj ## @@ -130,7 +131,8 @@ class SetDirectiveProcessor(TagProcessor.TagProcessor): validateSetDirective(templateObj, tag) firstEqualSign = tag.find('=') - varName = tag[0: firstEqualSign].replace('$','').strip() + varName = tag[0: firstEqualSign].replace( + templateObj.setting('placeholderStartToken'),'').strip() valueString = tag[firstEqualSign+1:] valueString = templateObj.translatePlaceholderVars(valueString, executeCallables=True) @@ -273,7 +275,8 @@ def preProcessMacroDirectives(templateObj, templateDef): macroBody = match.group(2).replace("'''","\'\'\'") - def handleArgsUsedInBody(match, argNamesList=argNamesList): + def handleArgsUsedInBody(match, argNamesList=argNamesList, + templateObj=templateObj): """check each $var in the macroBody to see if it is in this macro's argNamesList and needs substituting""" @@ -281,7 +284,8 @@ def preProcessMacroDirectives(templateObj, templateDef): if argName in argNamesList: return "''' + str(" + argName + ") + '''" else: - return '${' + match.group(1) + '}' + return templateObj.setting('placeholderStartToken') + \ + '{' + match.group(1) + '}' processor = templateObj.placeholderProcessor macroBody = processor.wrapPlaceholders( @@ -324,7 +328,7 @@ def preProcessLazyMacroCalls(templateObj, templateDef): except NameMapper.NotFound, name: line = lineNumFromPos(match.string, match.start()) - raise Error('Undeclared variable $' + str(name) + \ + raise Error('Undeclared variable ' + str(name) + \ ' used in macro call #'+ macroSignature + ' on line ' + str(line)) @@ -356,7 +360,7 @@ def preProcessExplicitMacroCalls(templateObj, templateDef): except NameMapper.NotFound, name: line = lineNumFromPos(match.string, match.start()) - raise Error('Undeclared variable $' + str(name) + + raise Error('Undeclared variable ' + str(name) + ' used in macro call #'+ macroSignature + ' on line ' + str(line)) @@ -399,7 +403,8 @@ def preProcessRawDirectives(templateObj, templateDef): unparsedBlock = match.group(1) blockID = '_' + str(id(unparsedBlock)) templateObj._rawTextBlocks[blockID] = unparsedBlock - return '#include raw $rawTextBlocks.' + blockID + '/#' + return '#include raw ' + templateObj.setting('placeholderStartToken') \ + + 'rawTextBlocks.' + blockID + '/#' if not hasattr(templateObj, '_rawTextBlocks'): templateObj._rawTextBlocks = {} @@ -436,7 +441,7 @@ def preProcessIncludeDirectives(templateObj, templateDef): raw = True args= ' '.join(args.split()[1:]) - if args[0] == '$': + if args[0] == templateObj.setting('placeholderStartToken'): searchList = templateObj.searchList() translatedArgs = templateObj.translatePlaceholderVars(args) includeString = eval( translatedArgs ) @@ -449,7 +454,8 @@ def preProcessIncludeDirectives(templateObj, templateDef): if raw: includeID = '_' + str(id(includeString)) templateObj._rawIncludes[includeID] = includeString - return '${rawIncludes.' + includeID + '}' + return templateObj.setting('placeholderStartToken') + \ + '{rawIncludes.' + includeID + '}' elif autoUpdate: includeID = '_' + str(id(includeString)) nestedTemplate = Template.Template( @@ -461,7 +467,8 @@ def preProcessIncludeDirectives(templateObj, templateDef): templateObj._parsedIncludes[includeID] = nestedTemplate if not hasattr(nestedTemplate, 'respond'): nestedTemplate.startServer() - return '${parsedIncludes.' + includeID + '}' + return templateObj.setting('placeholderStartToken') + \ + '{parsedIncludes.' + includeID + '}' else: RESTART[0] = True return includeString @@ -492,10 +499,12 @@ def preProcessBlockDirectives(templateObj, templateDef): markerEnd = templateObj._settings['blockMarkerEnd'] replaceString = markerStart[0] + blockName + markerStart[1] + \ - '#include $cheetahBlocks.' + blockName + '/#' + \ + '#include ' + templateObj.setting('placeholderStartToken') + \ + 'cheetahBlocks.' + blockName + '/#' + \ markerEnd[0] + blockName + markerEnd[1] else: - replaceString = '#include $cheetahBlocks.' + blockName + '/#' + replaceString = '#include ' + templateObj.setting('placeholderStartToken') + \ + 'cheetahBlocks.' + blockName + '/#' return templateDef[0:startTagMatch.start()] + replaceString + \ templateDef[endTagMatch.end():] @@ -553,10 +562,11 @@ def removeEmptyStrings(templateObj, generatedCode): ## varNotFound handlers ## def varNotFound_echo(templateObj, tag): - return "$" + tag + return templateObj.setting('placeholderStartToken') + tag def varNotFound_bigWarning(templateObj, tag): - return "="*15 + "<$" + tag + " could not be found>" + "="*15 + return "="*15 + "<" + templateObj.setting('placeholderStartToken') \ + + tag + " could not be found>" + "="*15 def varNotFound_KeyError(templateObj, tag): raise KeyError("no '%s' in this Template Object's Search List" % tag) diff --git a/src/NameMapper.py b/src/NameMapper.py index 458e995..28f8b5f 100644 --- a/src/NameMapper.py +++ b/src/NameMapper.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: NameMapper.py,v 1.4 2001/07/13 18:09:39 tavis_rudd Exp $ +# $Id: NameMapper.py,v 1.5 2001/08/03 19:20:50 tavis_rudd Exp $ """Utilities for accessing the members of an object via string representations of those members. Template processing is its primary intended use. @@ -58,13 +58,13 @@ Authors: Tavis Rudd <tavis@calrudd.com>, Chuck Esterbrook <echuck@mindspring.com> License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.4 $ +Version: $Revision: 1.5 $ Start Date: 2001/04/03 -Last Revision Date: $Date: 2001/07/13 18:09:39 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>," +\ "\nChuck Esterbrook <echuck@mindspring.com>" -__version__ = "$Revision: 1.4 $"[11:-2] +__version__ = "$Revision: 1.5 $"[11:-2] ################################################## ## DEPENDENCIES ## @@ -127,8 +127,10 @@ def valueForName(obj, name, default=NoDefault, executeCallables=False): def valueForKey(obj, key, default=NoDefault): - """Get the value of the specified key. The key can be a mapping item, an - attribute or an underscored attribute.""" + + """Get the value of the specified key. The 'obj' can be a a mapping or any + Python object that supports the __getattr__ method. The key can be a mapping + item, an attribute or an underscored attribute.""" if hasattr(obj, key): binding = getattr(obj, key) diff --git a/src/PlaceholderProcessor.py b/src/PlaceholderProcessor.py index 7d4b343..a6a8c18 100644 --- a/src/PlaceholderProcessor.py +++ b/src/PlaceholderProcessor.py @@ -1,19 +1,18 @@ #!/usr/bin/env python -# $Id: PlaceholderProcessor.py,v 1.16 2001/08/03 17:20:10 tavis_rudd Exp $ +# $Id: PlaceholderProcessor.py,v 1.17 2001/08/03 19:20:50 tavis_rudd Exp $ """Provides utilities for processing $placeholders in Cheetah templates - Meta-Data ================================================================================ Author: Tavis Rudd <tavis@calrudd.com>, License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.16 $ +Version: $Revision: 1.17 $ Start Date: 2001/03/30 -Last Revision Date: $Date: 2001/08/03 17:20:10 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.16 $"[11:-2] +__version__ = "$Revision: 1.17 $"[11:-2] ################################################## @@ -36,7 +35,9 @@ from Utilities import lineNumFromPos True = (1==1) False = (1==0) -placeholderTagsRE = re.compile(r'(?:(?<=\A)|(?<!\\))\$(?=[A-Za-z_\*\{])') +# define some RE chunks for use in PlaceholderProcessor.setTagStartToken() +escCharLookBehind = r'(?:(?<=\A)|(?<!\\))' +validSecondCharsLookAhead = r'(?=[A-Za-z_\*\{])' # cacheType's for $placeholders NO_CACHE = 0 @@ -68,15 +69,16 @@ class SyntaxError(ValueError): class PlaceholderProcessor(TagProcessor): """A class for processing $placeholders in strings.""" - def __init__(self, tagRE = placeholderTagsRE, marker=' placeholderTag.', + def __init__(self, tagStartToken = '$', marker=' placeholderTag.', markerEscaped = ' placeholderTag\.', markerLookBehind=r'(?:(?<= placeholderTag\.)|(?<= placeholderTag\.\{))'): """Setup the regexs used by this class - All $placeholders are translated into valid Python code by swapping $ - for the self._marker. This marker is then used to find the start of - each placeholder and allows $vars in function arg lists to be parsed - correctly. '$x()' becomes ' placeholderTag.x()' when it's marked. + All $placeholders are translated into valid Python code by swapping + 'tagStartToken' ($) for 'marker'. This marker is then used by the + parser (i.e. self.splitTxt()) to find the start of each placeholder and + allows $vars in function arg lists to be parsed correctly. '$x()' + becomes ' placeholderTag.x()' when it's marked. The marker starts with a space to allow $var$var to be parsed correctly. $a$b is translated to --placeholderTag.a placeholderTag.b-- instead of @@ -89,7 +91,7 @@ class PlaceholderProcessor(TagProcessor): r'\s*\*([0-9\.]+?)\*' + nameCharLookForward) - self._tagRE = tagRE + self.setTagStartToken(tagStartToken) self._marker = marker self._markerEscaped = markerEscaped self._markerLookBehind = markerLookBehind @@ -98,7 +100,52 @@ class PlaceholderProcessor(TagProcessor): self._nameRE = re.compile( marker + r'(?:CACHED\.|REFRESH_[0-9]+(?:_[0-9]+){0,1}\.){0,1}([A-Za-z_0-9\.]+)') + def setTagStartToken(self, theToken): + """Change the token used to identify the beginning of a + placeholderTag. The default is '$'.""" + + self._tagStartToken = theToken + theTokenEsc = re.sub(r'([\$\^\*\+\.\?\{\}\[\]\(\)\|\\])', r'\\\1' , theToken) + self.setTagStartTokenRE(re.compile(escCharLookBehind + + theTokenEsc + + validSecondCharsLookAhead)) + + def tagStartToken(self): + return self._tagStartToken + def setTagStartTokenRE(self, tagTokenRE): + """Change the regular expression used to identify the beginning of a + placeholderTag.""" + + self._tagStartTokenRE = tagTokenRE + + def escapePlaceholders(self, theString): + """Escape any escaped placeholders in the string.""" + + return theString.replace(self._tagStartToken, '\\' + self._tagStartToken) + def unescapePlaceholders(self, templateObj, theString): + """Unescape any escaped placeholders in the string. + + This method is called by the Template._codeGenerator() in stage 1, which + is why the first arg is 'templateObj. self.escapePlaceholders() isn't + called by Template._codeGenerator() so it doesn't take a templateObj arg.""" + + return theString.replace('\\' + self._tagStartToken, self._tagStartToken) + + def mark(self, txt): + """Swap the $'s for a marker that can be parsed as valid python code. + Default is 'placeholder.' + + Also mark whether the placeholder is to be statically cached or + timed-refresh cached""" + + txt = self._tagStartTokenRE.sub(self._marker, txt) + txt = self._cachedTags.sub('CACHED.', txt) + def refreshSubber(match): + return 'REFRESH_' + match.group(1).replace('.','_') + '.' + txt = self._refreshTags.sub(refreshSubber, txt) + return txt + def initializeTemplateObj(self, templateObj): """Initialize the templateObj so that all the necessary attributes are in place for the tag-processing stage""" @@ -129,20 +176,6 @@ class PlaceholderProcessor(TagProcessor): templateObj._timedRefreshList = [] templateObj._checkForCacheRefreshes = False - def mark(self, txt): - """Swap the $'s for a marker that can be parsed as valid python code. - Default is 'placeholder.' - - Also mark whether the placeholder is to be statically cached or - timed-refresh cached""" - - txt = self._tagRE.sub(self._marker, txt) - txt = self._cachedTags.sub('CACHED.', txt) - def refreshSubber(match): - return 'REFRESH_' + match.group(1).replace('.','_') + '.' - txt = self._refreshTags.sub(refreshSubber, txt) - return txt - def splitTxt(self, txt): """Split a text string containing marked placeholders diff --git a/src/Servlet.py b/src/Servlet.py index 6e24a8f..06df7c2 100644 --- a/src/Servlet.py +++ b/src/Servlet.py @@ -1,16 +1,16 @@ #!/usr/bin/env python -# $Id: Servlet.py,v 1.1 2001/06/13 03:50:39 tavis_rudd Exp $ +# $Id: Servlet.py,v 1.2 2001/08/03 19:20:50 tavis_rudd Exp $ """An abstract base class for Cheetah Servlets that can be used with Webware Meta-Data ================================================================================ Author: Tavis Rudd <tavis@calrudd.com>, -Version: $Revision: 1.1 $ +Version: $Revision: 1.2 $ Start Date: 2001/04/05 -Last Revision Date: $Date: 2001/06/13 03:50:39 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.1 $"[11:-2] +__version__ = "$Revision: 1.2 $"[11:-2] ################################################## ## DEPENDENCIES ## @@ -25,8 +25,16 @@ import CodeGenerator as CodeGen try: from WebKit.HTTPServlet import HTTPServlet except: - class HTTPServlet: - pass + ## for testing from the commandline or with TR's experimental rewrite of WebKit + class HTTPServlet: + _reusable = 1 + _threadSafe = 0 + + def awake(self, transaction): + pass + + def sleep(self, transaction): + pass ################################################## ## GLOBALS AND CONSTANTS ## @@ -40,7 +48,7 @@ False = (0==1) class TemplateServlet(Template, HTTPServlet): """An abstract base class for Cheetah servlets that can be used with Webware""" - + def __init__(self, template='', *searchList, **kw): """ """ if not kw.has_key('settings'): diff --git a/src/TagProcessor.py b/src/TagProcessor.py index 52499ed..7ad6753 100644 --- a/src/TagProcessor.py +++ b/src/TagProcessor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: TagProcessor.py,v 1.1 2001/08/02 05:48:34 tavis_rudd Exp $ +# $Id: TagProcessor.py,v 1.2 2001/08/03 19:20:50 tavis_rudd Exp $ """Tag Processor class Cheetah's codeGenerator Meta-Data @@ -7,12 +7,12 @@ Meta-Data Author: Tavis Rudd <tavis@calrudd.com> License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.1 $ +Version: $Revision: 1.2 $ Start Date: 2001/08/01 -Last Revision Date: $Date: 2001/08/02 05:48:34 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.1 $"[11:-2] +__version__ = "$Revision: 1.2 $"[11:-2] ################################################## ## DEPENDENCIES ## @@ -48,8 +48,12 @@ class TagProcessor: delims = templateObj.setting('internalDelims') tagTokenSeparator = templateObj.setting('tagTokenSeparator') def subber(match, delims=delims, token=self._token, - tagTokenSeparator=tagTokenSeparator): - tag = re.sub(r'(?:(?<=\A)|(?<!\\))\$',r'\$',match.group(1)) + tagTokenSeparator=tagTokenSeparator, + templateObj=templateObj): + + ## escape any placeholders in the tag so they aren't picked up as + ## top-level placeholderTags + tag = templateObj.placeholderProcessor.escapePlaceholders(match.group(1)) return delims[0] + token + tagTokenSeparator +\ tag + delims[1] diff --git a/src/Template.py b/src/Template.py index 1e18157..955ca4a 100644 --- a/src/Template.py +++ b/src/Template.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: Template.py,v 1.15 2001/08/02 06:17:11 tavis_rudd Exp $ +# $Id: Template.py,v 1.16 2001/08/03 19:20:50 tavis_rudd Exp $ """Provides the core Template class for Cheetah See the docstring in __init__.py and the User's Guide for more information @@ -8,12 +8,12 @@ Meta-Data Author: Tavis Rudd <tavis@calrudd.com> License: This software is released for unlimited distribution under the terms of the Python license. -Version: $Revision: 1.15 $ +Version: $Revision: 1.16 $ Start Date: 2001/03/30 -Last Revision Date: $Date: 2001/08/02 06:17:11 $ +Last Revision Date: $Date: 2001/08/03 19:20:50 $ """ __author__ = "Tavis Rudd <tavis@calrudd.com>" -__version__ = "$Revision: 1.15 $"[11:-2] +__version__ = "$Revision: 1.16 $"[11:-2] ################################################## @@ -72,6 +72,7 @@ class Template(SettingsManager): endCacheDirectiveProcessor = EndCacheDirectiveProcessor() _settings = { + 'placeholderStartToken':'$', 'useAutocalling': True, 'useLateBinding': True, 'delayedStart': False, @@ -150,7 +151,7 @@ class Template(SettingsManager): ('placeholders', placeholderProcessor.preProcess), ('unescapePlaceholders', - lambda obj, TD: TD.replace(r'\$','$') ), + placeholderProcessor.unescapePlaceholders), ], 'tagProcessors':{'placeholders':placeholderProcessor, @@ -213,7 +214,7 @@ class Template(SettingsManager): tup = tuple(kw['searchList']) self._searchList.extend(tup) # .extend requires a tuple. - # Unravel whether the user passed in a string, filename or file object. + ## Unravel whether the user passed in a string, filename or file object. self._fileName = None self._fileMtime = None file = kw.get('file', None) @@ -235,6 +236,8 @@ class Template(SettingsManager): else: raise TypeError("'file' argument must be a filename or file-like object") + + ## deal with other keywd args if kw.has_key('macros'): self._macros = kw['macros'] @@ -260,6 +263,8 @@ class Template(SettingsManager): self._templateDef = str( templateDef ) + self.placeholderProcessor.setTagStartToken(self.setting('placeholderStartToken')) + if not self._settings['delayedStart']: self.startServer() |