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
b8f3df8b
Commit
b8f3df8b
authored
Apr 24, 2002
by
Toby Dickenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merged toby-dtml-in-namespace-branch for collector 358: new dtml-in parameter no_push_item
parent
47d61f5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
lib/python/DocumentTemplate/DT_In.py
lib/python/DocumentTemplate/DT_In.py
+18
-8
lib/python/DocumentTemplate/tests/testDTML.py
lib/python/DocumentTemplate/tests/testDTML.py
+14
-2
No files found.
lib/python/DocumentTemplate/DT_In.py
View file @
b8f3df8b
...
...
@@ -76,8 +76,9 @@
need of reversing on the fly.
Within an 'in' block, variables are substituted from the
elements of the iteration. The elements may be either
instance or mapping objects. In addition, the variables:
elements of the iteration unless the 'no_push_item' optional
is specified. The elements may be either instance or mapping
objects. In addition, the variables:
'sequence-item' -- The element.
...
...
@@ -330,8 +331,8 @@
'''
#'
__rcs_id__
=
'$Id: DT_In.py,v 1.5
7 2001/11/28 15:50:54 matt
Exp $'
__version__
=
'$Revision: 1.5
7
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: DT_In.py,v 1.5
8 2002/04/24 14:38:40 htrd
Exp $'
__version__
=
'$Revision: 1.5
8
$'
[
11
:
-
2
]
import
sys
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
...
...
@@ -355,7 +356,7 @@ In=InFactory()
class
InClass
:
elses
=
None
expr
=
sort
=
batch
=
mapping
=
None
expr
=
sort
=
batch
=
mapping
=
no_push_item
=
None
start_name_re
=
None
reverse
=
None
sort_expr
=
reverse_expr
=
None
...
...
@@ -364,6 +365,7 @@ class InClass:
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
,
start
=
'1'
,
end
=
'-1'
,
size
=
'10'
,
orphan
=
'0'
,
overlap
=
'1'
,
mapping
=
1
,
no_push_item
=
1
,
skip_unauthorized
=
1
,
previous
=
1
,
next
=
1
,
expr
=
''
,
sort
=
''
,
reverse
=
1
,
sort_expr
=
''
,
reverse_expr
=
''
,
...
...
@@ -384,6 +386,9 @@ class InClass:
if
has_key
(
'reverse'
):
self
.
reverse
=
args
[
'reverse'
]
if
has_key
(
'no_push_item'
):
self
.
no_push_item
=
args
[
'no_push_item'
]
if
has_key
(
'mapping'
):
self
.
mapping
=
args
[
'mapping'
]
for
n
in
'start'
,
'size'
,
'end'
:
if
has_key
(
n
):
self
.
batch
=
1
...
...
@@ -453,6 +458,7 @@ class InClass:
params
=
self
.
args
mapping
=
self
.
mapping
no_push_item
=
self
.
no_push_item
if
self
.
sort_expr
is
not
None
:
self
.
sort
=
self
.
sort_expr
.
eval
(
md
)
...
...
@@ -584,7 +590,9 @@ class InClass:
if
t
is
TupleType
and
len
(
client
)
==
2
:
client
=
client
[
1
]
if
mapping
:
if
no_push_item
:
pushed
=
0
elif
mapping
:
pushed
=
1
push
(
client
)
elif
t
in
StringTypes
:
...
...
@@ -630,7 +638,7 @@ class InClass:
section
=
self
.
section
mapping
=
self
.
mapping
no_push_item
=
self
.
no_push_item
if
self
.
sort_expr
is
not
None
:
self
.
sort
=
self
.
sort_expr
.
eval
(
md
)
...
...
@@ -683,7 +691,9 @@ class InClass:
if
t
is
TupleType
and
len
(
client
)
==
2
:
client
=
client
[
1
]
if
mapping
:
if
no_push_item
:
pushed
=
0
elif
mapping
:
pushed
=
1
push
(
client
)
elif
t
in
StringTypes
:
...
...
lib/python/DocumentTemplate/tests/testDTML.py
View file @
b8f3df8b
...
...
@@ -13,8 +13,8 @@
"""Document Template Tests
"""
__rcs_id__
=
'$Id: testDTML.py,v 1.1
0 2002/02/06 19:13:36 chrisw
Exp $'
__version__
=
'$Revision: 1.1
0
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: testDTML.py,v 1.1
1 2002/04/24 14:38:41 htrd
Exp $'
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
import
sys
,
os
import
unittest
...
...
@@ -382,6 +382,18 @@ foo bar
assert
str
(
res
)
==
'success!'
,
`res`
def
testNoItemPush
(
self
):
data
=
d
(
sec
=
'B'
,
name
=
'XXX'
,
sub
=
(
d
(
name
=
'b1'
),
d
(
name
=
'b2'
,
sec
=
'XXX'
)))
html
=
"""
<dtml-with data mapping><dtml-in sub no_push_item>
<dtml-var sec>.<dtml-with sequence-item mapping><dtml-var name></dtml-with>
</dtml-in></dtml-with>
"""
expected
=
"""
B.b1 B.b2"""
result
=
self
.
doc_class
(
html
)(
data
=
data
)
assert
result
==
expected
,
result
def
testBasicHTMLIn
(
self
):
data
=
(
d
(
name
=
'jim'
,
age
=
39
),
...
...
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