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
12f9f634
Commit
12f9f634
authored
Sep 26, 2002
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Collector #538. Path expressions with a non-path final alternate no
longer try to call a value returned by that alternate.
parent
431601ab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+7
-2
lib/python/Products/PageTemplates/tests/testExpressions.py
lib/python/Products/PageTemplates/tests/testExpressions.py
+9
-0
No files found.
doc/CHANGES.txt
View file @
12f9f634
...
...
@@ -6,6 +6,9 @@ Zope Changes
Bugs Fixed
- Collector #538: Hybrid path expressions no longer attempt to call
a value returned by the final, non-path alternate.
- Collector #573: ZTUtils Iterator didn't catch AttributeError.
- Deprecated hasRole alias in User.py failed to return result.
...
...
lib/python/Products/PageTemplates/Expressions.py
View file @
12f9f634
...
...
@@ -17,7 +17,7 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, string literals, and paths.
"""
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
import
re
,
sys
from
TALES
import
Engine
,
CompilerError
,
_valid_name
,
NAME_RE
,
\
...
...
@@ -154,6 +154,7 @@ class PathExpr:
def
__init__
(
self
,
name
,
expr
,
engine
):
self
.
_s
=
expr
self
.
_name
=
name
self
.
_hybrid
=
0
paths
=
expr
.
split
(
'|'
)
self
.
_subexprs
=
[]
add
=
self
.
_subexprs
.
append
...
...
@@ -163,6 +164,7 @@ class PathExpr:
# This part is the start of another expression type,
# so glue it back together and compile it.
add
(
engine
.
compile
((
'|'
.
join
(
paths
[
i
:]).
lstrip
())))
self
.
_hybrid
=
1
break
add
(
SubPathExpr
(
path
).
_eval
)
...
...
@@ -187,8 +189,11 @@ class PathExpr:
else
:
break
else
:
# On the last subexpression allow exceptions through.
# On the last subexpression allow exceptions through, and
# don't autocall if the expression was not a subpath.
ob
=
self
.
_subexprs
[
-
1
](
econtext
)
if
self
.
_hybrid
:
return
ob
if
self
.
_name
==
'nocall'
or
isinstance
(
ob
,
StringType
):
return
ob
...
...
lib/python/Products/PageTemplates/tests/testExpressions.py
View file @
12f9f634
...
...
@@ -43,6 +43,15 @@ class ExpressionTests(unittest.TestCase):
assert
ec
.
evaluate
(
'd/ | nothing'
)
==
'blank'
assert
ec
.
evaluate
(
'd/?blank'
)
==
'blank'
def
testHybrid
(
self
):
'''Test hybrid path expressions'''
ec
=
self
.
ec
assert
ec
.
evaluate
(
'x | python:1+1'
)
==
2
assert
ec
.
evaluate
(
'x | python:int'
)
==
int
assert
ec
.
evaluate
(
'x | string:x'
)
==
'x'
assert
ec
.
evaluate
(
'x | string:$one'
)
==
'1'
assert
ec
.
evaluate
(
'x | not:exists:x'
)
def
test_suite
():
return
unittest
.
makeSuite
(
ExpressionTests
)
...
...
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