Commit 8e636c00 authored by Amos Latteier's avatar Amos Latteier

STX improvements to the DTML Reference. Also slightly improved the...

STX improvements to the DTML Reference. Also slightly improved the documentation of dtml-var entity syntax (again).
parent cc1022d3
...@@ -9,39 +9,41 @@ functions: DTML Functions ...@@ -9,39 +9,41 @@ functions: DTML Functions
be a plain or long integer or a floating point number. If the argument be a plain or long integer or a floating point number. If the argument
is a complex number, its magnitude is returned. is a complex number, its magnitude is returned.
chr(integer) -- Return a string of one character whose ASCII code is chr(integer) -- Return a string of one character whose ASCII code
the integer i, e.g., chr(97) returns the string 'a'. This is the is the integer, e.g., 'chr(97)' returns the string 'a'. This is
inverse of ord(). The argument must be in the range [0..255], the inverse of ord(). The argument must be in the range 0 to 255,
inclusive; ValueError will be raised if i is outside that range. inclusive; 'ValueError' will be raised if the integer is outside
that range.
DateTime() -- Returns a Zope 'DateTime' object given constructor DateTime() -- Returns a Zope 'DateTime' object given constructor
arguments. See the "DateTime":DateTime.py API reference for more arguments. See the "DateTime":DateTime.py API reference for more
information on constructor arguments. information on constructor arguments.
divmod(number, number) -- Take two numbers as arguments and return a divmod(number, number) -- Take two numbers as arguments and return
pair of numbers consisting of their quotient and remainder when using a pair of numbers consisting of their quotient and remainder when
long division. With mixed operand types, the rules for binary using long division. With mixed operand types, the rules for
arithmetic operators apply. For plain and long integers, the result binary arithmetic operators apply. For plain and long integers,
is the same as (a / b, a % b). For floating point numbers the result the result is the same as '(a / b, a % b)'. For floating point
is (q, a % b), where q is usually math.floor(a / b) but may be 1 numbers the result is '(q, a % b)', where *q* is usually
less than that. In any case q * b + a % b is very close to a, if a % 'math.floor(a / b)' but may be 1 less than that. In any case 'q *
b is non-zero it has the same sign as b, and 0 <= abs(a % b) < b + a % b' is very close to *a*, if 'a % b' is non-zero it has the
abs(b). same sign as *b*, and '0 <= abs(a % b) < abs(b)'.
float(number) -- Convert a string or a number to floating point. If the float(number) -- Convert a string or a number to floating
argument is a string, it must contain a possibly signed decimal or point. If the argument is a string, it must contain a possibly
floating point number, possibly embedded in whitespace; this signed decimal or floating point number, possibly embedded in
behaves identical to string.atof(x). Otherwise, the argument may be whitespace; this behaves identical to
a plain or long integer or a floating point number, and a floating 'string.atof(number)'. Otherwise, the argument may be a plain or
point number with the same value (within Python's floating point long integer or a floating point number, and a floating point
number with the same value (within Python's floating point
precision) is returned. precision) is returned.
getattr(object, string) -- Return the value of the named attributed of getattr(object, string) -- Return the value of the named
object. name must be a string. If the string is the name of one of the attributed of object. name must be a string. If the string is the
object's attributes, the result is the value of that attribute. For name of one of the object's attributes, the result is the value of
example, getattr(x, 'foobar') is equivalent to x.foobar. If the named that attribute. For example, 'getattr(x, "foobar")' is equivalent
attribute does not exist, default is returned if provided, otherwise to 'x.foobar'. If the named attribute does not exist, default is
AttributeError is raised. returned if provided, otherwise 'AttributeError' is raised.
getitem(variable, render=0) -- Returns the value of a DTML variable. getitem(variable, render=0) -- Returns the value of a DTML variable.
If 'render' is true, the variable is rendered. If 'render' is true, the variable is rendered.
...@@ -63,22 +65,23 @@ functions: DTML Functions ...@@ -63,22 +65,23 @@ functions: DTML Functions
hex(integer) -- Convert an integer number (of any size) to a hex(integer) -- Convert an integer number (of any size) to a
hexadecimal string. The result is a valid Python expression. Note: this hexadecimal string. The result is a valid Python expression. Note: this
always yields an unsigned literal, e.g. on a 32-bit machine, hex(-1) always yields an unsigned literal, e.g. on a 32-bit machine, 'hex(-1)'
yields '0xffffffff'. When evaluated on a machine with the same word yields '0xffffffff'. When evaluated on a machine with the same word
size, this literal is evaluated as -1; at a different word size, it size, this literal is evaluated as -1; at a different word size, it
may turn up as a large positive number or raise an OverflowError may turn up as a large positive number or raise an 'OverflowError'
exception. exception.
int(number) -- Convert a string or number to a plain integer. If the int(number) -- Convert a string or number to a plain integer. If
argument is a string, it must contain a possibly signed decimal number the argument is a string, it must contain a possibly signed
representable as a Python integer, possibly embedded in whitespace; decimal number representable as a Python integer, possibly
this behaves identical to string.atoi(x[, radix]). The radix parameter embedded in whitespace; this behaves identical to
gives the base for the conversion and may be any integer in the range 'string.atoi(number[, radix]'). The 'radix' parameter gives the
[2, 36]. If radix is specified and x is not a string, TypeError is base for the conversion and may be any integer in the range 2 to
raised. Otherwise, the argument may be a plain or long integer or a 36. If 'radix' is specified and the number is not a string,
floating point number. Conversion of floating point numbers to integers 'TypeError' is raised. Otherwise, the argument may be a plain or
is defined by the C semantics; normally the conversion truncates long integer or a floating point number. Conversion of floating
towards zero. point numbers to integers is defined by the C semantics; normally
the conversion truncates towards zero.
len(sequence) -- Return the length (the number of items) of an len(sequence) -- Return the length (the number of items) of an
object. The argument may be a sequence (string, tuple or list) or a object. The argument may be a sequence (string, tuple or list) or a
...@@ -98,36 +101,37 @@ functions: DTML Functions ...@@ -98,36 +101,37 @@ functions: DTML Functions
oct(integer) -- Convert an integer number (of any size) to an octal oct(integer) -- Convert an integer number (of any size) to an octal
string. The result is a valid Python expression. Note: this always string. The result is a valid Python expression. Note: this always
yields an unsigned literal, e.g. on a 32-bit machine, oct(-1) yields yields an unsigned literal, e.g. on a 32-bit machine, 'oct(-1)' yields
'037777777777'. When evaluated on a machine with the same word size, '037777777777'. When evaluated on a machine with the same word size,
this literal is evaluated as -1; at a different word size, it may this literal is evaluated as -1; at a different word size, it may
turn up as a large positive number or raise an OverflowError turn up as a large positive number or raise an OverflowError
exception. exception.
ord(character) -- Return the ASCII value of a string of one ord(character) -- Return the ASCII value of a string of one
character. E.g., ord('a') returns the integer 97. This is the character. E.g., 'ord("a")' returns the integer 97. This is the
inverse of chr(). inverse of 'chr()'.
pow(x, y [,z]) -- Return x to the power y; if z is present, return pow(x, y [,z]) -- Return *x* to the power *y*; if *z* is present,
x to the power y, modulo z (computed more efficiently than pow(x, y) % return *x* to the power *y*, modulo *z* (computed more efficiently
z). The arguments must have numeric types. With mixed operand types, than 'pow(x, y) % z'). The arguments must have numeric types. With
the rules for binary arithmetic operators apply. The effective operand mixed operand types, the rules for binary arithmetic operators
type is also the type of the result; if the result is not expressible apply. The effective operand type is also the type of the result;
in this type, the function raises an exception; e.g., pow(2, -1) or if the result is not expressible in this type, the function raises
pow(2, 35000) is not allowed. an exception; e.g., 'pow(2, -1)' or 'pow(2, 35000)' is not
allowed.
range([start,] stop [,step]) -- This is a versatile function to range([start,] stop [,step]) -- This is a versatile function to
create lists containing arithmetic progressions. create lists containing arithmetic progressions. The arguments
The arguments must be plain integers. If the must be plain integers. If the step argument is omitted, it
step argument is omitted, it defaults to 1. If the start argument defaults to 1. If the start argument is omitted, it defaults to
is omitted, it defaults to 0. The full form returns a 0. The full form returns a list of plain integers '[start, start
list of plain integers [start, start + step, start + 2 * step, + step, start + 2 * step, ...]'. If step is positive, the last
...]. If step is positive, the last element is the largest element is the largest 'start + i * step' less than *stop*; if
start + i * step less than stop; if step is negative, the last *step* is negative, the last element is the largest 'start + i *
element is the largest start + i * step greater than stop. step step' greater than *stop*. *step* must not be zero (or else
must not be zero (or else ValueError is raised). 'ValueError' is raised).
round(x [,n]) -- Return the floating point value x rounded to n round(x [,n]) -- Return the floating point value *x* rounded to *n*
digits after the decimal point. If n is omitted, it defaults to digits after the decimal point. If n is omitted, it defaults to
zero. The result is a floating point number. Values are rounded to the zero. The result is a floating point number. Values are rounded to the
closest multiple of 10 to the power minus n; if two multiples are closest multiple of 10 to the power minus n; if two multiples are
......
...@@ -11,7 +11,7 @@ math: DTML Math Functions ...@@ -11,7 +11,7 @@ math: DTML Math Functions
atan(x) -- Return the arc tangent of *x* atan(x) -- Return the arc tangent of *x*
atan2(x, y) -- Return *atan(y / x)*. atan2(x, y) -- Return 'atan(y / x)'.
ceil(x) -- Return the ceiling of *x* as a real. ceil(x) -- Return the ceiling of *x* as a real.
...@@ -25,24 +25,24 @@ math: DTML Math Functions ...@@ -25,24 +25,24 @@ math: DTML Math Functions
floor(x) -- Return the floor of *x* as a real. floor(x) -- Return the floor of *x* as a real.
fmod(x, y) -- Return fmod(x, y), as defined by the platform C fmod(x, y) -- Return 'fmod(x, y)', as defined by the platform C
library. Note that the Python expression *x % y* may not return the library. Note that the Python expression 'x % y' may not return
same result. the same result.
fexp(x) -- Return the mantissa and exponent of *x* as the pair (m, e). m fexp(x) -- Return the mantissa and exponent of *x* as the pair '(m, e)'. *m*
is a float and e is an integer such that 'x == m * 2**e'. If x is zero, is a float and *e* is an integer such that 'x == m * 2**e'. If
returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. *x* is zero, returns '(0.0, 0)', otherwise '0.5 <= abs(m) < 1'.
hypot(x, y) -- Return the Euclidean distance, sqrt(x*x + y*y). hypot(x, y) -- Return the Euclidean distance, 'sqrt(x*x + y*y)'.
ldexp(x, y) -- Return x * (2**i). ldexp(x, y) -- Return 'x * (2**i)'.
log(x) -- Return the natural logarithm of *x*. log(x) -- Return the natural logarithm of *x*.
log10(x) -- Return the base-10 logarithm of *x*. log10(x) -- Return the base-10 logarithm of *x*.
modf(x) -- Return the fractional and integer parts of x. Both results modf(x) -- Return the fractional and integer parts of *x*. Both results
carry the sign of x. The integer part is returned as a real. carry the sign of *x*. The integer part is returned as a real.
pow(x, y) -- Return *x* to the power of *y*. pow(x, y) -- Return *x* to the power of *y*.
......
...@@ -20,17 +20,19 @@ var: Inserts a variable ...@@ -20,17 +20,19 @@ var: Inserts a variable
&dtml-variableName; &dtml-variableName;
Entity syntax is a short cut which inserts and HTML quotes the Entity syntax is a short cut which inserts and HTML quotes the
variable. It is useful when inserting variables into HTML tags. variable. It is useful when inserting variables into HTML
tags.
'var' tag entity syntax with attributes:: 'var' tag entity syntax with attributes::
&dtml.attribute1[.attribute2]...-variableName; &dtml.attribute1[.attribute2]...-variableName;
To a limited degree you may specify attributes with the entity To a limited degree you may specify attributes with the entity
syntax. You may include one or more attributes delimited by syntax. You may include zero or more attributes delimited by
periods. You cannot provide arguments for attributes using the periods. You cannot provide arguments for attributes using the
entity syntax. If you provide attributes, then the variable is not entity syntax. If you provide zero or more attributes, then the
automatically HTML quoted. variable is not automatically HTML quoted. Thus you can avoid HTML
quoting with this syntax, '&dtml.-variableName;'.
Attributes Attributes
......
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