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
7c473b10
Commit
7c473b10
authored
Jan 14, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added expr to unless.
parent
eea8b328
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
lib/python/DocumentTemplate/DT_If.py
lib/python/DocumentTemplate/DT_If.py
+22
-13
No files found.
lib/python/DocumentTemplate/DT_If.py
View file @
7c473b10
...
@@ -117,8 +117,8 @@ __doc__='''Conditional insertion
...
@@ -117,8 +117,8 @@ __doc__='''Conditional insertion
# (540) 371-6909
# (540) 371-6909
#
#
############################################################################
############################################################################
__rcs_id__
=
'$Id: DT_If.py,v 1.
7 1998/01/14 18:03:25
jim Exp $'
__rcs_id__
=
'$Id: DT_If.py,v 1.
8 1998/01/14 18:23:42
jim Exp $'
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
from
DT_Util
import
*
from
DT_Util
import
*
import
sys
import
sys
...
@@ -166,10 +166,10 @@ class If:
...
@@ -166,10 +166,10 @@ class If:
if
ev
is
not
name
:
if
ev
is
not
name
:
raise
KeyError
,
name
,
sys
.
exc_traceback
raise
KeyError
,
name
,
sys
.
exc_traceback
v
=
None
v
=
None
cache
[
name
]
=
v
else
:
else
:
v
=
expr
.
eval
(
md
)
v
=
expr
.
eval
(
md
)
cache
[
name
]
=
v
if
v
:
return
section
(
None
,
md
)
if
v
:
return
section
(
None
,
md
)
if
self
.
elses
:
return
self
.
elses
(
None
,
md
)
if
self
.
elses
:
return
self
.
elses
(
None
,
md
)
...
@@ -186,13 +186,16 @@ class Unless:
...
@@ -186,13 +186,16 @@ class Unless:
def
__init__
(
self
,
blocks
):
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
)
args
=
parse_params
(
args
,
name
=
''
,
expr
=
''
)
name
=
name_param
(
args
)
name
,
expr
=
name_param
(
args
,
'unless'
,
1
)
self
.
__name__
=
name
self
.
__name__
=
name
self
.
section
=
section
self
.
section
=
section
self
.
expr
=
expr
def
render
(
self
,
md
):
def
render
(
self
,
md
):
name
=
self
.
__name__
name
=
self
.
__name__
expr
=
self
.
expr
if
expr
is
None
:
try
:
v
=
md
[
name
]
try
:
v
=
md
[
name
]
except
KeyError
,
ev
:
except
KeyError
,
ev
:
if
ev
is
not
name
:
raise
KeyError
,
name
,
sys
.
exc_traceback
if
ev
is
not
name
:
raise
KeyError
,
name
,
sys
.
exc_traceback
...
@@ -201,6 +204,9 @@ class Unless:
...
@@ -201,6 +204,9 @@ class Unless:
md
.
_push
({
name
:
v
})
md
.
_push
({
name
:
v
})
try
:
return
self
.
section
(
None
,
md
)
try
:
return
self
.
section
(
None
,
md
)
finally
:
md
.
_pop
(
1
)
finally
:
md
.
_pop
(
1
)
else
:
if
not
expr
.
eval
(
md
):
return
self
.
section
(
None
,
md
)
return
''
return
''
__call__
=
render
__call__
=
render
...
@@ -213,6 +219,9 @@ class Else(Unless):
...
@@ -213,6 +219,9 @@ class Else(Unless):
##########################################################################
##########################################################################
#
#
# $Log: DT_If.py,v $
# $Log: DT_If.py,v $
# Revision 1.8 1998/01/14 18:23:42 jim
# Added expr to unless.
#
# Revision 1.7 1998/01/14 18:03:25 jim
# Revision 1.7 1998/01/14 18:03:25 jim
# Added Unless tag as replacement for else tag.
# Added Unless tag as replacement for else tag.
#
#
...
...
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