Commit 69b6187e authored by Jim Fulton's avatar Jim Fulton

Updated parse_params so that you can define an attribute that, if

used, must have a value.  This is done by specifying None as a default
value.
parent 4463587c
'''$Id: DT_Util.py,v 1.15 1997/11/12 19:44:13 jim Exp $''' '''$Id: DT_Util.py,v 1.16 1997/11/19 15:33:32 jim Exp $'''
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
import sys, regex, string, types, math, os import sys, regex, string, types, math, os
from string import rfind, strip, joinfields, atoi,lower,upper,capitalize from string import rfind, strip, joinfields, atoi,lower,upper,capitalize
...@@ -210,7 +210,7 @@ Python expression support ...@@ -210,7 +210,7 @@ Python expression support
<!--#var expr="_.string.lower(title)"--> <!--#var expr="_.string.lower(title)"-->
""" """ #"
def parse_params(text, def parse_params(text,
result=None, result=None,
...@@ -258,9 +258,13 @@ def parse_params(text, ...@@ -258,9 +258,13 @@ def parse_params(text,
name=unparmre.group(2) name=unparmre.group(2)
l=len(unparmre.group(1)) l=len(unparmre.group(1))
if result.has_key(''): if result.has_key(''):
if parms.has_key(name): result[name]=parms[name] if parms.has_key(name):
if parms[name] is None: raise ParseError, (
'Attribute %s requires a value' % name, tag)
result[name]=parms[name]
else: raise ParseError, ( else: raise ParseError, (
'Invalid parameter name, "%s"' % name, tag) 'Invalid attribute name, "%s"' % name, tag)
else: else:
result['']=name result['']=name
return apply(parse_params,(text[l:],result),parms) return apply(parse_params,(text[l:],result),parms)
...@@ -270,7 +274,7 @@ def parse_params(text, ...@@ -270,7 +274,7 @@ def parse_params(text,
if not parms.has_key(name): if not parms.has_key(name):
raise ParseError, ( raise ParseError, (
'Invalid parameter name, "%s"' % name, tag) 'Invalid attribute name, "%s"' % name, tag)
result[name]=value result[name]=value
...@@ -285,6 +289,11 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks ...@@ -285,6 +289,11 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
############################################################################ ############################################################################
# $Log: DT_Util.py,v $ # $Log: DT_Util.py,v $
# Revision 1.16 1997/11/19 15:33:32 jim
# Updated parse_params so that you can define an attribute that, if
# used, must have a value. This is done by specifying None as a default
# value.
#
# Revision 1.15 1997/11/12 19:44:13 jim # Revision 1.15 1997/11/12 19:44:13 jim
# Took out setting __roles__ for pop and push. # Took out setting __roles__ for pop and push.
# #
......
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