Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
Zope
Commits
6b06cd66
Commit
6b06cd66
authored
23 years ago
by
Evan Simpson
Browse files
Options
Download
Email Patches
Plain Diff
Fix repeat variable
parent
1b45e39a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+4
-1
lib/python/Products/PageTemplates/TALES.py
lib/python/Products/PageTemplates/TALES.py
+5
-4
lib/python/Products/PageTemplates/tests/input/Loop1.html
lib/python/Products/PageTemplates/tests/input/Loop1.html
+3
-2
lib/python/Products/PageTemplates/tests/output/Loop1.html
lib/python/Products/PageTemplates/tests/output/Loop1.html
+9
-3
No files found.
lib/python/Products/PageTemplates/Expressions.py
View file @
6b06cd66
...
...
@@ -89,7 +89,7 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, Python string literals, and paths.
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
re
,
sys
from
TALES
import
Engine
,
CompilerError
,
_valid_name
,
NAME_RE
...
...
@@ -167,6 +167,9 @@ class PathExpr:
ob
=
var
[
base
]
else
:
ob
=
contexts
[
base
]
# Work around lack of security declaration
if
path
and
(
ob
is
contexts
[
'repeat'
]):
ob
=
ob
[
path
.
pop
(
0
)]
ob
=
restrictedTraverse
(
ob
,
path
)
except
(
AttributeError
,
KeyError
):
if
self
.
_name
==
'exists'
:
...
...
This diff is collapsed.
Click to expand it.
lib/python/Products/PageTemplates/TALES.py
View file @
6b06cd66
...
...
@@ -87,7 +87,7 @@
An implementation of a generic TALES engine
"""
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
re
,
sys
from
MultiMapping
import
MultiMapping
...
...
@@ -209,7 +209,7 @@ class Context:
# Keep track of what contexts get pushed as each scope begins.
self
.
_ctxts_pushed
=
[]
# These contexts will need to be pushed.
self
.
_current_ctxts
=
{
'local'
:
1
,
'
loop
'
:
1
}
self
.
_current_ctxts
=
{
'local'
:
1
,
'
repeat
'
:
1
}
contexts
[
'local'
]
=
lv
=
MultiMapping
()
init_local
=
contexts
.
get
(
'local'
,
None
)
...
...
@@ -218,7 +218,8 @@ class Context:
contexts
[
'global'
]
=
gv
=
contexts
.
copy
()
gv
[
'standard'
]
=
contexts
contexts
[
'var'
]
=
MultiMapping
(
gv
,
lv
)
contexts
[
'loop'
]
=
MultiMapping
()
contexts
[
'repeat'
]
=
rep
=
MultiMapping
()
contexts
[
'loop'
]
=
rep
# alias
def
beginScope
(
self
):
oldctxts
=
self
.
_current_ctxts
...
...
@@ -246,7 +247,7 @@ class Context:
def
setRepeat
(
self
,
name
,
expr
):
expr
=
self
.
evaluate
(
expr
)
it
=
self
.
_engine
.
Iterator
(
name
,
expr
,
self
)
self
.
_current_ctxts
[
'
loop
'
][
name
]
=
it
self
.
_current_ctxts
[
'
repeat
'
][
name
]
=
it
return
it
def
evaluate
(
self
,
expression
):
...
...
This diff is collapsed.
Click to expand it.
lib/python/Products/PageTemplates/tests/input/Loop1.html
View file @
6b06cd66
...
...
@@ -6,8 +6,9 @@
<p>
Choose your type:
</p>
<ul>
<li
tal:repeat=
"type python:'digital', 'analog', 'organic'"
>
<a
href=
"dummy"
tal:attributes=
"href string:/mach/$type"
tal:content=
"type"
>
selection
</a>
<a
href=
"dummy"
tal:attributes=
"href string:/mach/$type"
>
<span
tal:replace=
"repeat/type/number"
>
1
</span>
.
<span
tal:replace=
"type"
>
selection
</span></a>
</li>
</ul>
</body>
...
...
This diff is collapsed.
Click to expand it.
lib/python/Products/PageTemplates/tests/output/Loop1.html
View file @
6b06cd66
...
...
@@ -6,13 +6,19 @@
<p>
Choose your type:
</p>
<ul>
<li>
<a
href=
"/mach/digital"
>
digital
</a>
<a
href=
"/mach/digital"
>
1.
digital
</a>
</li>
<li>
<a
href=
"/mach/analog"
>
analog
</a>
<a
href=
"/mach/analog"
>
2.
analog
</a>
</li>
<li>
<a
href=
"/mach/organic"
>
organic
</a>
<a
href=
"/mach/organic"
>
3.
organic
</a>
</li>
</ul>
</body>
...
...
This diff is collapsed.
Click to expand it.
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