[Zope-Checkins] SVN: Zope/branches/gsoc-python-2.5/lib/python/ - Convert another string exception to normal exception
Sidnei da Silva
sidnei at enfoldsystems.com
Mon Oct 13 17:31:17 EDT 2008
Log message for revision 92176:
- Convert another string exception to normal exception
Changed:
U Zope/branches/gsoc-python-2.5/lib/python/DocumentTemplate/DT_Util.py
U Zope/branches/gsoc-python-2.5/lib/python/Shared/DC/ZRDB/sqlvar.py
-=-
Modified: Zope/branches/gsoc-python-2.5/lib/python/DocumentTemplate/DT_Util.py
===================================================================
--- Zope/branches/gsoc-python-2.5/lib/python/DocumentTemplate/DT_Util.py 2008-10-13 21:07:59 UTC (rev 92175)
+++ Zope/branches/gsoc-python-2.5/lib/python/DocumentTemplate/DT_Util.py 2008-10-13 21:31:16 UTC (rev 92176)
@@ -42,7 +42,9 @@
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 @@
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 @@
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 @@
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 @@
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
Modified: Zope/branches/gsoc-python-2.5/lib/python/Shared/DC/ZRDB/sqlvar.py
===================================================================
--- Zope/branches/gsoc-python-2.5/lib/python/Shared/DC/ZRDB/sqlvar.py 2008-10-13 21:07:59 UTC (rev 92175)
+++ Zope/branches/gsoc-python-2.5/lib/python/Shared/DC/ZRDB/sqlvar.py 2008-10-13 21:31:16 UTC (rev 92176)
@@ -78,10 +78,10 @@
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__
More information about the Zope-Checkins
mailing list