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
e6a756ad
Commit
e6a756ad
authored
May 13, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the way that '_' is handled. It is now an alias for the template dict.
parent
bb8ccdb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
27 deletions
+41
-27
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+35
-24
lib/python/DocumentTemplate/VSEval.py
lib/python/DocumentTemplate/VSEval.py
+6
-3
No files found.
lib/python/DocumentTemplate/DT_Util.py
View file @
e6a756ad
'''$Id: DT_Util.py,v 1.3
1 1998/04/02 17:37:37
jim Exp $'''
'''$Id: DT_Util.py,v 1.3
2 1998/05/13 21:09:23
jim Exp $'''
############################################################################
############################################################################
# Copyright
# Copyright
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
# (540) 371-6909
# (540) 371-6909
#
#
############################################################################
############################################################################
__version__
=
'$Revision: 1.3
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
2
$'
[
11
:
-
2
]
import
sys
,
regex
,
string
,
types
,
math
,
os
import
sys
,
regex
,
string
,
types
,
math
,
os
from
string
import
rfind
,
strip
,
joinfields
,
atoi
,
lower
,
upper
,
capitalize
from
string
import
rfind
,
strip
,
joinfields
,
atoi
,
lower
,
upper
,
capitalize
...
@@ -92,6 +92,22 @@ def careful_getattr(md, inst, name):
...
@@ -92,6 +92,22 @@ def careful_getattr(md, inst, name):
raise
ValidationError
,
name
raise
ValidationError
,
name
def
careful_hasattr
(
md
,
inst
,
name
):
try
:
if
name
[:
1
]
!=
'_'
:
validate
=
md
.
validate
if
validate
is
None
:
return
hasattr
(
inst
,
name
)
if
hasattr
(
inst
,
'aq_acquire'
):
inst
.
aq_acquire
(
name
,
validate
,
md
)
return
1
v
=
getattr
(
inst
,
name
)
if
validate
(
inst
,
inst
,
name
,
v
,
md
):
return
1
except
:
pass
return
0
def
careful_getitem
(
md
,
mapping
,
key
):
def
careful_getitem
(
md
,
mapping
,
key
):
v
=
mapping
[
key
]
v
=
mapping
[
key
]
...
@@ -119,21 +135,20 @@ def careful_getslice(md, seq, *indexes):
...
@@ -119,21 +135,20 @@ def careful_getslice(md, seq, *indexes):
return
v
return
v
import
string
,
math
,
rand
,
whrandom
import
string
,
math
,
whrandom
class
expr_globals
:
pas
s
try
:
from
cDocumentTemplate
import
InstanceDict
,
TemplateDict
,
render_block
s
ex
pr_globals
=
expr_globals
()
ex
cept
:
from
pDocumentTemplate
import
InstanceDict
,
TemplateDict
,
render_blocks
d
=
expr_globals
.
__dict__
d
=
TemplateDict
.
__dict__
for
name
in
(
'None'
,
'abs'
,
'chr'
,
'divmod'
,
'float'
,
'hash'
,
'hex'
,
'int'
,
for
name
in
(
'None'
,
'abs'
,
'chr'
,
'divmod'
,
'float'
,
'hash'
,
'hex'
,
'int'
,
'len'
,
'max'
,
'min'
,
'oct'
,
'ord'
,
'pow'
,
'round'
,
'str'
):
'len'
,
'max'
,
'min'
,
'oct'
,
'ord'
,
'pow'
,
'round'
,
'str'
):
d
[
name
]
=
__builtins__
[
name
]
d
[
name
]
=
__builtins__
[
name
]
d
[
'string'
]
=
string
d
[
'string'
]
=
string
d
[
'math'
]
=
math
d
[
'math'
]
=
math
d
[
'rand'
]
=
rand
d
[
'whrandom'
]
=
whrandom
d
[
'whrandom'
]
=
whrandom
def
test
(
*
args
):
def
test
(
self
,
*
args
):
l
=
len
(
args
)
l
=
len
(
args
)
for
i
in
range
(
1
,
l
,
2
):
for
i
in
range
(
1
,
l
,
2
):
if
args
[
i
-
1
]:
return
args
[
i
]
if
args
[
i
-
1
]:
return
args
[
i
]
...
@@ -142,14 +157,13 @@ def test(*args):
...
@@ -142,14 +157,13 @@ def test(*args):
d
[
'test'
]
=
test
d
[
'test'
]
=
test
def
_attr
(
inst
,
name
,
md
=
{}):
d
[
'attr'
]
=
careful_getattr
return
careful_getattr
(
md
,
inst
,
name
)
d
[
'getattr'
]
=
careful_getattr
d
[
'hasattr'
]
=
careful_hasattr
d
[
'attr'
]
=
_attr
class
namespace_
:
pass
class
namespace_
:
pass
def
namespace
(
**
kw
):
def
namespace
(
self
,
**
kw
):
r
=
namespace_
()
r
=
namespace_
()
d
=
r
.
__dict__
d
=
r
.
__dict__
for
k
,
v
in
kw
.
items
():
d
[
k
]
=
v
for
k
,
v
in
kw
.
items
():
d
[
k
]
=
v
...
@@ -159,7 +173,6 @@ d['namespace']=namespace
...
@@ -159,7 +173,6 @@ d['namespace']=namespace
expr_globals
=
{
expr_globals
=
{
'__builtins__'
:{},
'__builtins__'
:{},
'_'
:
expr_globals
,
'__guarded_mul__'
:
VSEval
.
careful_mul
,
'__guarded_mul__'
:
VSEval
.
careful_mul
,
'__guarded_getattr__'
:
careful_getattr
,
'__guarded_getattr__'
:
careful_getattr
,
'__guarded_getitem__'
:
careful_getitem
,
'__guarded_getitem__'
:
careful_getitem
,
...
@@ -221,15 +234,15 @@ Python expression support
...
@@ -221,15 +234,15 @@ Python expression support
In addition, certain special additional names are available:
In addition, certain special additional names are available:
'_
vars
' -- Provides access to the document template namespace as a
'_' -- Provides access to the document template namespace as a
mapping object. This variable can be useful for accessing
mapping object. This variable can be useful for accessing
objects in a document template namespace that have names that are
objects in a document template namespace that have names that are
not legal Python variable names::
not legal Python variable names::
<!--#var expr="_
vars
['sequence-number']*5"-->
<!--#var expr="_['sequence-number']*5"-->
'_' -- Provides access to a Python module containing
standard
This variable also has attributes that provide access to
standard
utility objects. These
utility object
s include:
utility objects. These
attribute
s include:
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
...
@@ -252,7 +265,7 @@ Python expression support
...
@@ -252,7 +265,7 @@ Python expression support
<!--#var expr="_.string.lower(title)"-->
<!--#var expr="_.string.lower(title)"-->
"""
#"
"""
def
parse_params
(
text
,
def
parse_params
(
text
,
result
=
None
,
result
=
None
,
...
@@ -324,13 +337,11 @@ def parse_params(text,
...
@@ -324,13 +337,11 @@ def parse_params(text,
if text: return apply(parse_params,(text,result),parms)
if text: return apply(parse_params,(text,result),parms)
else: return result
else: return result
try: from cDocumentTemplate import InstanceDict, TemplateDict, render_blocks
except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
#from cDocumentTemplate import InstanceDict, TemplateDict, render_blocks
############################################################################
############################################################################
# $Log: DT_Util.py,v $
# $Log: DT_Util.py,v $
# Revision 1.32 1998/05/13 21:09:23 jim
# Changed the way that '
_
' is handled. It is now an alias for the template dict.
#
# Revision 1.31 1998/04/02 17:37:37 jim
# Revision 1.31 1998/04/02 17:37:37 jim
# Major redesign of block rendering. The code inside a block tag is
# Major redesign of block rendering. The code inside a block tag is
# compiled as a template but only the templates blocks are saved, and
# compiled as a template but only the templates blocks are saved, and
...
...
lib/python/DocumentTemplate/VSEval.py
View file @
e6a756ad
"""Very Safe Python Expressions
"""Very Safe Python Expressions
"""
"""
__rcs_id__
=
'$Id: VSEval.py,v 1.1
2 1998/04/02 17:37:39
jim Exp $'
__rcs_id__
=
'$Id: VSEval.py,v 1.1
3 1998/05/13 21:10:30
jim Exp $'
############################################################################
############################################################################
# Copyright
# Copyright
...
@@ -11,7 +11,7 @@ __rcs_id__='$Id: VSEval.py,v 1.12 1998/04/02 17:37:39 jim Exp $'
...
@@ -11,7 +11,7 @@ __rcs_id__='$Id: VSEval.py,v 1.12 1998/04/02 17:37:39 jim Exp $'
# rights reserved.
# rights reserved.
#
#
############################################################################
############################################################################
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
from
string
import
join
,
find
,
split
,
translate
from
string
import
join
,
find
,
split
,
translate
import
sys
,
gparse
,
string
import
sys
,
gparse
,
string
...
@@ -110,7 +110,7 @@ class Eval:
...
@@ -110,7 +110,7 @@ class Eval:
self
.
used
=
tuple
(
used
.
keys
())
self
.
used
=
tuple
(
used
.
keys
())
def
eval
(
self
,
mapping
):
def
eval
(
self
,
mapping
):
d
=
{
'_vars
'
:
mapping
}
d
=
{
'_vars'
:
mapping
,
'_
'
:
mapping
}
code
=
self
.
code
code
=
self
.
code
globals
=
self
.
globals
globals
=
self
.
globals
for
name
in
self
.
used
:
for
name
in
self
.
used
:
...
@@ -132,6 +132,9 @@ compiled_getattr=compile(
...
@@ -132,6 +132,9 @@ compiled_getattr=compile(
############################################################################
############################################################################
#
#
# $Log: VSEval.py,v $
# $Log: VSEval.py,v $
# Revision 1.13 1998/05/13 21:10:30 jim
# Changed the way that '_' is handled. It is now an alias for the template dict.
#
# Revision 1.12 1998/04/02 17:37:39 jim
# Revision 1.12 1998/04/02 17:37:39 jim
# Major redesign of block rendering. The code inside a block tag is
# Major redesign of block rendering. The code inside a block tag is
# compiled as a template but only the templates blocks are saved, and
# compiled as a template but only the templates blocks are saved, and
...
...
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