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
b1880be9
Commit
b1880be9
authored
Mar 04, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an 'only' flag attribute that can be used to prevent
inclusion of enclosing namespaces.
parent
0cb6960b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
lib/python/DocumentTemplate/DT_With.py
lib/python/DocumentTemplate/DT_With.py
+17
-8
No files found.
lib/python/DocumentTemplate/DT_With.py
View file @
b1880be9
...
...
@@ -105,11 +105,11 @@
'''
__rcs_id__
=
'$Id: DT_With.py,v 1.
7 1998/12/04 20:15:28
jim Exp $'
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: DT_With.py,v 1.
8 1999/03/04 18:39:31
jim Exp $'
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
InstanceDict
,
render_blocks
,
str
from
DT_Util
import
TemplateDict
class
With
:
blockContinuations
=
()
name
=
'with'
...
...
@@ -117,24 +117,33 @@ class With:
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
,
expr
=
''
,
mapping
=
1
)
args
=
parse_params
(
args
,
name
=
''
,
expr
=
''
,
mapping
=
1
,
only
=
1
)
name
,
expr
=
name_param
(
args
,
'with'
,
1
)
if
expr
is
None
:
expr
=
name
else
:
expr
=
expr
.
eval
self
.
__name__
,
self
.
expr
=
name
,
expr
self
.
section
=
section
.
blocks
if
args
.
has_key
(
'mapping'
)
and
args
[
'mapping'
]:
self
.
mapping
=
1
if
args
.
has_key
(
'only'
)
and
args
[
'only'
]:
self
.
only
=
1
def
render
(
self
,
md
):
expr
=
self
.
expr
if
type
(
expr
)
is
type
(
''
):
v
=
md
[
expr
]
else
:
v
=
expr
(
md
)
if
self
.
mapping
:
md
.
_push
(
v
)
else
:
if
not
self
.
mapping
:
if
type
(
v
)
is
type
(())
and
len
(
v
)
==
1
:
v
=
v
[
0
]
md
.
_push
(
InstanceDict
(
v
,
md
))
v
=
InstanceDict
(
v
,
md
)
if
self
.
only
:
_md
=
md
md
=
TemplateDict
()
if
hasattr
(
_md
,
'AUTHENTICATED_USER'
):
md
.
AUTHENTICATED_USER
=
_md
.
AUTHENTICATED_USER
if
hasattr
(
_md
,
'validate'
):
md
.
validate
=
_md
.
validate
md
.
_push
(
v
)
try
:
return
render_blocks
(
self
.
section
,
md
)
finally
:
md
.
_pop
(
1
)
...
...
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