Commit fe08653e authored by Amos Latteier's avatar Amos Latteier

typo fixes and added examples to TALES docs

parent da91863a
......@@ -22,6 +22,6 @@ TALES Exists expressions
</p>
Note that in this case you can't use the expression,
"not:request/form/number", since that expression will be true if
'not:request/form/number', since that expression will be true if
the 'number' variable exists and is zero.
\ No newline at end of file
......@@ -50,7 +50,7 @@ TALES Path expressions
then in globals, then in this list, these names act just like
built-ins in Python; They are always available, but they can be
shadowed by a global or local variable declaration. You can always
access the built-in names explicitely by prefixing them with
access the built-in names explicitly by prefixing them with
*CONTEXTS*. (e.g. CONTEXTS/root, CONTEXTS/nothing, etc).
Examples
......
......@@ -14,7 +14,24 @@ TALES Python expressions
Security Restrictions
XXX
Python expressions are subject to the same security restrictions
as Python-based scripts. These restrictions include:
loop limits -- Python expressions cannot create infinite loops.
import limits -- Python expressions can only access some Python
modules. See below for details.
access limits -- Python expressions are subject to Zope
permission and role security restrictions. In addition,
expressions cannot access objects whose names begin with
underscore.
write limits -- Python expressions cannot change attributes of
Zope objects.
Despite these limits malicious Python expressions can cause
problems. See The Zope Book for more information.
Built-in Functions
......@@ -32,9 +49,9 @@ TALES Python expressions
keep them from generating very large numbers and sequences. This
limitation helps protect against denial of service attacks.
In addition, these DTML utility functions are available:
'DateTime', 'test', 'namespace', 'render'. See XXX for more
information on these functions.
In addition, these utility functions are available: 'DateTime',
'test', 'same_type'. See XXX for more information on these
functions.
Finally, these functions are available in Python expressions,
but not in Python-based scripts:
......@@ -53,13 +70,25 @@ TALES Python expressions
Python Modules
string -- XXX
A number of Python modules are available by default. You can
make more modules available. See XXX for more information. You
can access modules either via path expressions (for example
'modules/string/join') or in Python with the 'modules' mapping
object (for example 'modules["string"].join'). Here are the
default modules:
'string' -- The standard "Python string
module":http://www.python.org/doc/current/lib/module-string.html. Note:
most of the functions in the module are also available as
methods on string objects.
random -- XXX
'random' -- The standard "Python random
module":http://www.python.org/doc/current/lib/module-random.html.
math -- XXX
'math' -- The standard "Python math
module":http://www.python.org/doc/current/lib/module-math.html.
Products.PythonScripts.standard -- XXX
'Products.PythonScripts.standard' -- XXX
ZPTUtils.* -- XXX
......@@ -67,7 +96,30 @@ TALES Python expressions
Examples
XXX
Basic module usage::
<span tal:replace="python:modules['random'].choice(['one',
'two', 'three', 'four', 'five'])">
a random number between one and five
</span>
String processing (capitalize the user name)::
<p tal:content="python:user.getUserName().capitalize()">
User Name
</p>
Basic math (convert image size to mega bytes)::
<p tal:content="python:image.getSize() / 1048576.0">
12.2323
</p>
String formatting (format a float to two decimal places)::
<p tal:content="python:'%0.2f' % size">
13.56
</p>
See Also
......
......@@ -21,4 +21,20 @@ TALES String expressions
Examples
XXX
\ No newline at end of file
Basic string formatting::
<span tal:replace="string:$this and $that">
this and that
</span>
Variables with longer paths::
<p tal:content="total: ${request/form/total}">
total: 12
</p>
Including a dollar sign::
<p tal:content="cost: $$$cost">
cost: $42.00
</p>
TALES Overview
The *Template Attribute Language Expression Syntax* (TALES) standard
describes expressions that suppy "TAL":tal.stx and "METAL":metal.stx
with data. TALES is *one* possible expression syntax for these
languages, but they are not bound to this definition. Similarly,
TALES could be used in a context having nothing to do with TAL or
METAL.
describes expressions that supply "TAL":tal.stx and
"METAL":metal.stx with data. TALES is *one* possible expression
syntax for these languages, but they are not bound to this
definition. Similarly, TALES could be used in a context having
nothing to do with TAL or METAL.
TALES expressions are described below with any delimiter or quote
markup from higher language layers removed. Here is the basic
......@@ -72,7 +72,7 @@ TALES Overview
attributes of the current statement tag.
- *CONTEXTS* - the list of standard names (this list). This can be
used to access a builtin variable that has been hidden by a local
used to access a built-in variable that has been hidden by a local
or global variable with the same name.
- *root* - the system's top-most object. In Zope this corresponds
......@@ -100,7 +100,9 @@ TALES Overview
See Also
"TAL overview":tal.stx
"TAL Overview":tal.stx
"METAL Overview":metal.stx
"exists":tales-exists.stx expressions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment