Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a538bdcd
Commit
a538bdcd
authored
Oct 13, 2008
by
Sidnei da Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Convert another string exception to normal exception
parent
620e5d16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+17
-15
lib/python/Shared/DC/ZRDB/sqlvar.py
lib/python/Shared/DC/ZRDB/sqlvar.py
+2
-2
No files found.
lib/python/DocumentTemplate/DT_Util.py
View file @
a538bdcd
...
@@ -42,7 +42,9 @@ LIMITED_BUILTINS = 1
...
@@ -42,7 +42,9 @@ LIMITED_BUILTINS = 1
str
=
__builtins__
[
'str'
]
# Waaaaa, waaaaaaaa needed for pickling waaaaa
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
from
zExceptions
import
Unauthorized
as
ValidationError
def
int_param
(
params
,
md
,
name
,
default
=
0
,
st
=
type
(
''
)):
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):
...
@@ -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
v
[:
1
]
==
'"'
and
v
[
-
1
:]
==
'"'
and
len
(
v
)
>
1
:
# expr shorthand
if
used
(
attr
):
if
used
(
attr
):
raise
ParseError
,
(
'%s and expr given'
%
attr
,
tag
)
raise
ParseError
(
'%s and expr given'
%
attr
,
tag
)
if
expr
:
if
expr
:
if
used
(
'expr'
):
if
used
(
'expr'
):
raise
ParseError
,
(
'two exprs given'
,
tag
)
raise
ParseError
(
'two exprs given'
,
tag
)
v
=
v
[
1
:
-
1
]
v
=
v
[
1
:
-
1
]
try
:
expr
=
Eval
(
v
)
try
:
expr
=
Eval
(
v
)
except
SyntaxError
,
v
:
except
SyntaxError
,
v
:
raise
ParseError
,
(
raise
ParseError
(
'<strong>Expression (Python) Syntax error</strong>:'
'<strong>Expression (Python) Syntax error</strong>:'
'
\
n
<pre>
\
n
%s
\
n
</pre>
\
n
'
%
v
[
0
],
'
\
n
<pre>
\
n
%s
\
n
</pre>
\
n
'
%
v
[
0
],
tag
)
tag
)
return
v
,
expr
return
v
,
expr
else
:
raise
ParseError
,
(
else
:
raise
ParseError
(
'The "..." shorthand for expr was used in a tag '
'The "..." shorthand for expr was used in a tag '
'that doesn
\
'
t support expr attributes.'
,
'that doesn
\
'
t support expr attributes.'
,
tag
)
tag
)
else
:
# name shorthand
else
:
# name shorthand
if
used
(
attr
):
if
used
(
attr
):
raise
ParseError
,
(
'Two %s values were given'
%
attr
,
tag
)
raise
ParseError
(
'Two %s values were given'
%
attr
,
tag
)
if
expr
:
if
expr
:
if
used
(
'expr'
):
if
used
(
'expr'
):
# raise 'Waaaaaa', 'waaa'
# raise 'Waaaaaa', 'waaa'
raise
ParseError
,
(
'%s and expr given'
%
attr
,
tag
)
raise
ParseError
(
'%s and expr given'
%
attr
,
tag
)
return
params
[
''
],
None
return
params
[
''
],
None
return
params
[
''
]
return
params
[
''
]
elif
used
(
attr
):
elif
used
(
attr
):
if
expr
:
if
expr
:
if
used
(
'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
],
None
return
params
[
attr
]
return
params
[
attr
]
elif
expr
and
used
(
'expr'
):
elif
expr
and
used
(
'expr'
):
...
@@ -286,7 +288,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -286,7 +288,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
expr
=
Eval
(
name
)
expr
=
Eval
(
name
)
return
name
,
expr
return
name
,
expr
raise
ParseError
,
(
'No %s given'
%
attr
,
tag
)
raise
ParseError
(
'No %s given'
%
attr
,
tag
)
Expr_doc
=
"""
Expr_doc
=
"""
...
@@ -399,11 +401,11 @@ def parse_params(text,
...
@@ -399,11 +401,11 @@ def parse_params(text,
l
=
len
(
mo_unp
.
group
(
1
))
l
=
len
(
mo_unp
.
group
(
1
))
if
result
:
if
result
:
if
parms
.
has_key
(
name
):
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
)
'Attribute %s requires a value'
%
name
,
tag
)
result
[
name
]
=
parms
[
name
]
result
[
name
]
=
parms
[
name
]
else
:
raise
ParseError
,
(
else
:
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
else
:
else
:
result
[
''
]
=
name
result
[
''
]
=
name
...
@@ -411,22 +413,22 @@ def parse_params(text,
...
@@ -411,22 +413,22 @@ def parse_params(text,
elif
mo_unq
:
elif
mo_unq
:
name
=
mo_unq
.
group
(
2
)
name
=
mo_unq
.
group
(
2
)
l
=
len
(
mo_unq
.
group
(
1
))
l
=
len
(
mo_unq
.
group
(
1
))
if
result
:
raise
ParseError
,
(
if
result
:
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
else
:
result
[
''
]
=
name
else
:
result
[
''
]
=
name
return
parse_params
(
text
[
l
:],
result
,
**
parms
)
return
parse_params
(
text
[
l
:],
result
,
**
parms
)
else
:
else
:
if
not
text
or
not
text
.
strip
():
return
result
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
):
if
not
parms
.
has_key
(
name
):
raise
ParseError
,
(
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
if
result
.
has_key
(
name
):
if
result
.
has_key
(
name
):
p
=
parms
[
name
]
p
=
parms
[
name
]
if
type
(
p
)
is
not
ListType
or
p
:
if
type
(
p
)
is
not
ListType
or
p
:
raise
ParseError
,
(
raise
ParseError
(
'Duplicate values for attribute "%s"'
%
name
,
tag
)
'Duplicate values for attribute "%s"'
%
name
,
tag
)
result
[
name
]
=
value
result
[
name
]
=
value
...
...
lib/python/Shared/DC/ZRDB/sqlvar.py
View file @
a538bdcd
...
@@ -78,10 +78,10 @@ class SQLVar:
...
@@ -78,10 +78,10 @@ class SQLVar:
self
.
args
=
args
self
.
args
=
args
if
not
args
.
has_key
(
'type'
):
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'
]
t
=
args
[
'type'
]
if
not
valid_type
(
t
):
if
not
valid_type
(
t
):
raise
ParseError
,
(
'invalid type, %s'
%
t
,
'dtvar'
)
raise
ParseError
(
'invalid type, %s'
%
t
,
'dtvar'
)
def
render
(
self
,
md
):
def
render
(
self
,
md
):
name
=
self
.
__name__
name
=
self
.
__name__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment