Commit a538bdcd authored by Sidnei da Silva's avatar Sidnei da Silva

- Convert another string exception to normal exception

parent 620e5d16
......@@ -42,7 +42,9 @@ LIMITED_BUILTINS = 1
str=__builtins__['str'] # Waaaaa, waaaaaaaa needed for pickling waaaaa
ParseError='Document Template Parse Error'
class ParseError(Exception):
"""Document Template Parse Error"""
from zExceptions import Unauthorized as ValidationError
def int_param(params,md,name,default=0, st=type('')):
......@@ -248,37 +250,37 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
if v[:1]=='"' and v[-1:]=='"' and len(v) > 1: # expr shorthand
if used(attr):
raise ParseError, ('%s and expr given' % attr, tag)
raise ParseError('%s and expr given' % attr, tag)
if expr:
if used('expr'):
raise ParseError, ('two exprs given', tag)
raise ParseError('two exprs given', tag)
v=v[1:-1]
try: expr=Eval(v)
except SyntaxError, v:
raise ParseError, (
raise ParseError(
'<strong>Expression (Python) Syntax error</strong>:'
'\n<pre>\n%s\n</pre>\n' % v[0],
tag)
return v, expr
else: raise ParseError, (
else: raise ParseError(
'The "..." shorthand for expr was used in a tag '
'that doesn\'t support expr attributes.',
tag)
else: # name shorthand
if used(attr):
raise ParseError, ('Two %s values were given' % attr, tag)
raise ParseError('Two %s values were given' % attr, tag)
if expr:
if used('expr'):
# raise 'Waaaaaa', 'waaa'
raise ParseError, ('%s and expr given' % attr, tag)
raise ParseError('%s and expr given' % attr, tag)
return params[''],None
return params['']
elif used(attr):
if expr:
if used('expr'):
raise ParseError, ('%s and expr given' % attr, tag)
raise ParseError('%s and expr given' % attr, tag)
return params[attr],None
return params[attr]
elif expr and used('expr'):
......@@ -286,7 +288,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
expr=Eval(name)
return name, expr
raise ParseError, ('No %s given' % attr, tag)
raise ParseError('No %s given' % attr, tag)
Expr_doc="""
......@@ -399,11 +401,11 @@ def parse_params(text,
l=len(mo_unp.group(1))
if result:
if parms.has_key(name):
if parms[name] is None: raise ParseError, (
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 attribute name, "%s"' % name, tag)
else:
result['']=name
......@@ -411,22 +413,22 @@ def parse_params(text,
elif mo_unq:
name=mo_unq.group(2)
l=len(mo_unq.group(1))
if result: raise ParseError, (
if result: raise ParseError(
'Invalid attribute name, "%s"' % name, tag)
else: result['']=name
return parse_params(text[l:],result,**parms)
else:
if not text or not text.strip(): return result
raise ParseError, ('invalid parameter: "%s"' % text, tag)
raise ParseError('invalid parameter: "%s"' % text, tag)
if not parms.has_key(name):
raise ParseError, (
raise ParseError(
'Invalid attribute name, "%s"' % name, tag)
if result.has_key(name):
p=parms[name]
if type(p) is not ListType or p:
raise ParseError, (
raise ParseError(
'Duplicate values for attribute "%s"' % name, tag)
result[name]=value
......
......@@ -78,10 +78,10 @@ class SQLVar:
self.args=args
if not args.has_key('type'):
raise ParseError, ('the type attribute is required', 'dtvar')
raise ParseError('the type attribute is required', 'dtvar')
t=args['type']
if not valid_type(t):
raise ParseError, ('invalid type, %s' % t, 'dtvar')
raise ParseError('invalid type, %s' % t, 'dtvar')
def render(self, md):
name=self.__name__
......
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