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
0870866c
Commit
0870866c
authored
Oct 29, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved func_code from DT_Util to DT_String.
Took stab at expression documentation.
parent
71c1f515
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
7 deletions
+56
-7
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+56
-7
No files found.
lib/python/DocumentTemplate/DT_Util.py
View file @
0870866c
'''$Id: DT_Util.py,v 1.1
2 1997/10/29 21:30:24
jim Exp $'''
'''$Id: DT_Util.py,v 1.1
3 1997/10/29 22:06:06
jim Exp $'''
############################################################################
# Copyright
...
...
@@ -52,7 +52,7 @@
# (540) 371-6909
#
############################################################################
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
sys
,
regex
,
string
,
types
,
math
,
os
from
string
import
rfind
,
strip
,
joinfields
,
atoi
,
lower
,
upper
,
capitalize
...
...
@@ -74,11 +74,6 @@ def int_param(params,md,name,default=0):
v
=
atoi
(
v
)
return
v
class
func_code
:
def
__init__
(
self
,
varnames
=
(
'self'
,
'REQUEST'
)):
self
.
co_varnames
=
varnames
self
.
co_argcount
=
len
(
varnames
)
def
_tm
(
m
,
tag
):
return
m
+
tag
and
(
' in %s'
%
tag
)
...
...
@@ -161,6 +156,55 @@ def name_param(params,tag='',expr=0):
raise
ParseError
,
(
'No name given'
,
tag
)
Expr_doc
=
"""
Python expression support
Several document template tags, including 'var', 'in', 'if', 'else',
and 'elif' provide support for using Python expressions via an
'expr' tag attribute.
Expressions may be used where a simple variable value is
inadequate. For example, an expression might be used to test
whether a variable is greater than some amount::
<!--#if expr="age > 18"-->
or to transform some basic data::
<!--#var expr="phone[:3]"-->
Objects available in the document templates namespace may be used.
Subobjects of these objects may be used as well, although subobject
access is restricted by the optional validation method.
In addition, certain special additional names are available:
'_vars' -- Provides access to the document template namespace as a
mapping object. This variable can be useful for accessing
objects in a document template namespace that have names that are
not legal Python variable names::
<!--#var expr="_vars['sequence-number']*5"-->
'_' -- Provides access to a Python module containing standard
utility objects. These utility objects include:
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
'round', and 'str' from the standard Python builtin module.
- The Python 'string' module, and
- The Python 'math' module.
For example, to convert a value to lower case::
<!--#var expr="_.string.lower(title)"-->
"""
def
parse_params
(
text
,
result
=
None
,
tag
=
''
,
...
...
@@ -234,6 +278,11 @@ TemplateDict.pop.__roles__=TemplateDict.push.__roles__=()
############################################################################
# $Log: DT_Util.py,v $
# Revision 1.13 1997/10/29 22:06:06 jim
# Moved func_code from DT_Util to DT_String.
#
# Took stab at expression documentation.
#
# Revision 1.12 1997/10/29 21:30:24 jim
# Added "builtin" objects.
#
...
...
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