Zope Quick Reference

Version 0.8


Brian Hooper

David Kankiewicz

Evelyn Mitchell

Stephan Richter

 

Index


DTML
Syntax
variable names
Tags
_ (special namespace variable)
Zope-defined Web request variables
CGI-defined Web request variables
Document Templates
Default Document Source
structured Text
XML Document

Object Reference
Zope Objects and Methods

Object Reference
Common methods
DTML Document methods
DTML Method
DTML Method
ZSQL Method
External Method
File
Folder
Image
Mail Host
Object Manager
P SQL Input Wizard
Product
User Folder
Version
Version Management
ZCatalog
ZClass
Zope Draft (depreciated, Broken 1.x)
Zope Factory
DateTime
Find

Zope General Information
Security Measures
Undo Section
Find Interface
Control Panel
Versions
Product Management
Add


DTML

Syntax

Tag
Zope 2.x only

Entity-reference syntax (equivalent to )
<dtml-tagname attribute1="value1" attribute2="value2" ...> </dtml-tagname>

Tag
Zope 1.x (deprecated)


<!--#tag-name attribute1="value1" attribute2="value2" ... -->

Python String Format
Zope 1.x (deprecated)


%(tag-name attribute1="value1" attribute2="value2")s

variable names

object ids
All versions

[a-zA-Z0-9-_~\,\. ] Object ids can include letters, numbers, or any of the characters dash (-), underscore (_), tilde (~), comma (,), period (.), or space ( ). Object ids may not begin with an underscore. Object ids must be unique with respect to their containing object (i.e., within a Folder 'foo', there can only one object with the id 'bar') and must also not conflict with property ids of the container (in the above example, Folder 'foo' cannot have a property 'bar' if it contains an object called 'bar'). If the variable name could be interpreted as a python expression, (in particular, if the name contains '-' or '.') when used in the 'expr' attribute of a DTML tag it can only be referenced using the namespace variable, i.e.: <dtml-if expr="_['sequence-length' ] > 20">

property ids
all versions

Property ids can contain any printable characters other than space ( ). Property ids, like object ids, may not begin with an underscore. Property ids must be unique with respect to their containing object; for example, Folder 'foo' can only have one property 'color' (Note: insert info here about property types)

Tags

General

Describes general and global functionalities of DTML tags.
name
(may be omitted) - the name of the variable data, caches the value name="input_name" input_name
capitalize
The first letter of the inserted text should be capitalized.
expr
Syntax is that of Python.


expr="age > 18"
"age < 18"
x*2+3
func(a,b)
obj.title
obj.meth(a,b)
(age < 12 or age > 65) and status == 'student'
REQUEST['HTTP_REFERER' ] - gets the HTTP_REFERER

var

Substitutes variable data into text.

Zope automatically defines the DTML methods standard_html_header and standard_html_footer. They define the usual HTML things, like the header and the body tag. To incorporate them into your DTML/HTML Document or Method you need to use the var tag as follows: <dtml-var standard_html_header>
Note: When you create a DTML Document or Method the standard_html_header and standard_html_footer are automatically inserted for you. They currently use the old way: <!--#var standard_html_header>

Another good example, that makes use of the 'fmt' attribute is displaying the current time in Zope. Again, Zope has a predefined object called 'ZopeTime' that will return a the output of DateTime.now() which is a DateTime object (not a string). Let's say you want to just display the date and not the time. You can do this with a predefined 'Date-Time format' or use the common 'strftime syntax'. Here are both ways of doing this: <dtml-var ZopeTime fmt=date> or <dtml-var ZopeTime fmt="%m/%d/%Y">

name=arg
See general tag.
expr=arg
See general tag.
fmt=arg
The choices are between specifying a special, custom or C-style format.
special
whole-dollars
Show a numeric value with a dollar symbol.
dollars-and-cents
Show a numeric value with a dollar symbol and two decimal places.
collection-length
Show the length of a collection of objects.
structured-text
Show the name or expr as Structured Text (see the Structured Text section for details).
Date-time
AMPM
Return the time string for an object to the nearest second.
AMPMMinutes
Return the time string for an object not showing seconds.
aCommon
Return the time string for an object not showing seconds.
aCommonZ
Return the time string for an object not showing seconds.
aDay
Return the time string for an object not showing seconds.
aMonth
Return the time string for an object not showing seconds.
ampm
Return the appropriate time modifier (am or pm).
Date
Return the date string for the object.
Day
Return the full name of the day of the week.
DayOfWeek
Compatibility: see Day.
day
Return the integer day.
dayOfYear
Return the day of the year, in context of the time-zone representation of the object.
dd
Return day as a 2 digit string.
fCommon
Return a string representing the object's value with the format: March 1, 1997 1:45 pm.
fCommonZ
Return a string representing the object's value with the format: March 1, 1997 1:45 pm US/Eastern.
h_12
Return the 12-hour clock representation of the hour.
h_24
Return the 24-hour clock representation of the hour.
hour
Return the 24-hour clock representation of the hour.
isCurrentHour
Return true if this object represents a date/time that falls within the current hour, in the context of this object's time-zone representation.
isCurrentMonth
Return true if this object represents a date/time that falls within the current month, in the context of this object's time-zone representation.
isFuture
Return true if this object represents a date/time later than the time of the call.
isLeapYear
Return true if the current year (in the context of the object's time zone) is a leap year.
isPast
Return true if this object represents a date/time earlier than the time of the call.
Mon_
Return the full month name.
Mon
Compatibility: see aMonth.
Month
Return the full month name.
minute
Return the minute.
mm
Return month as a 2 digit string.
month
Return the month of the object as an integer.
notEqualTo(t)
Compare this DateTime object to another DateTime object OR a floating point number, such as that which is returned by the python time module. Returns true if the object represents a date/time not equal to the specified DateTime or time module style time.
PreciseAMPM
Return the time string for the object.
PreciseTime
Return the time string for the object.
pCommon
Return a string representing the object's value with the format: Mar. 1, 1997 1:45 pm.
pCommonZ
Return a string representing the object's value with the format: Mar. 1, 1997 1:45 pm US/Eastern.
pDay
Return the abbreviated (with period) name of the day of the week.
pMonth
Return the abbreviated (with period) month name.
rfc822
Return the date in RFC 822 format.
second
Return the second.
TimeMinutes
Return the time string for an object not showing seconds.
Time
Return the time string for an object to the nearest second.
timezone
Return the time zone in which the object is represented.
year
Return the calendar year of the object
yy
Return calendar year as a 2 digit string.
strftime-style
%a
Locale's abbreviated weekday name.
%A
Locale's full weekday name.
%b
Locale's abbreviated month name.
%B
Locale's full month name.
%c
Locale's appropriate date and time representation.
%d
Day of the month as a decimal number [01,31].
%H
Hour (24-hour clock) as a decimal number [00,23].
%I
Hour (12-hour clock) as a decimal number [01,12].
%j
Day of the year as a decimal number [001,366].
%m
Month as a decimal number [01,12].
%M
Minute as a decimal number [00,59].
%p
Locale's equivalent of either AM or PM.
%S
Second as a decimal number [00,61].
%U
Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
%w
Weekday as a decimal number [0(Sunday),6].
%W
Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
%x
Locale's appropriate date representation.
%X
Locale's appropriate time representation.
%y
Year without century as a decimal number [00,99].
%Y
Year with century as a decimal number.
%Z
Time zone name (or by no characters if no time zone exists).
%%
%
C-style
d
Signed decimal integer.
e
Scientific notation.
E
Scientific Notation (upper case E).
f
Decimal floating point.
g
Shorter of e or f.
G
Shorter of E or F.
I
Signed decimal integers.
o
Unsigned octal.
s
String of characters.
u
Unsigned decimal integers.
x
Unsigned hexadecimal lowercase.
X
Unsigned hexadecimal uppercase.
null=arg
Specifies what should be displayed in case of a NULL (None) value.
<dtml-var cost fmt="$%.2d" null='n/a'>
lower
Cause all upper-case letters to be converted to lower case.
upper
Cause all lower-case letters to be converted to upper case.
capitalize
Cause the first character of the inserted value to be converted to upper-case.
spacify
Cause underscores in the inserted value to be converted to spaces.
thousands_commas
Cause commas to be inserted every three digits to the left of a decimal point in values containing numbers (i.e., "12000 widgets" becomes "12,000 widgets").
html_quote
Convert characters that have special meaning in HTML to HTML character entities.
url_quote
Convert characters that have special meaning in URLs to HTML character entities using decimal values.
sql_quote
Convert single quotes to pairs of single quotes. This is needed to safely include values in SQL strings.
newline_to_br
Convert newlines and carriage-return and newline combinations to break tags.
size=arg
Truncates a string argument at the given length (Note: if a space occurs in the second half of the truncated string, then the string is further truncated to the right-most space).
etc=arg
Specifies a string to add to the end of a string which has been truncated (by setting the size= attribute listed above). By default, this is '...' For example, if spam is the string 'red yellow green', then
<dtml-var spam size=10 etc=", etc.">
will produce the output
red yellow, etc.

if [elif]* [else] /if

Allows you to do Programming level logic.
<dtml-if argument>
(block)
<dtml-elif argument>
(block)
<dtml-else>
(block)
</dtml-if>

Let's say you had a form and one of the choices was to select the gender and to type in the last name of the person. Now knowing the gender you want to address the person in the right way. Here how you would do it:
<dtml-with REQUEST>
<dtml-if "gender == 'female'">
Dear Misses <dtml-var name>,
<dtml-elif "gender == 'male'"
Dear Mister <dtml-var name>,
<dtml-else>
Dear Misses or Mister <dtml-var name>,
</dtml-if>
</dtml-with>

name
See general tag.
expr
See general tag.

unless /unless

evaluates the enclosed content if a condition is false.
name
See general tag.
expr
See general tag.

in [else] /in

Iterative Insertion
<dtml-in list>
(block)
<dtml-else>
(block)
</dtml-in>


name=arg
See general tag.
expr=arg
See general tag.
mapping
Normally, the attributes of items in the sequence are displayed. But, some items should be treated as mapping objects, meaning that the items are to be looked up.
reverse
sort=arg
The sort attribute is used to cause a sequence of objects to be sorted before text insertion is performed. The attribute value is the name of the attribute (or key if the mapping attribute was provided) that items should be sorted on.
start=arg
The name of a (request) variable that specifies the number of the row on which to start a batch
size=arg
The batch size.
skip_unauthorized
Use of this attribute causes items to be skipped if access to the item is unauthorized. See Access Control. If this attribute is not used, then Unauthorized errors are raised if unauthorized items are encountered.
orphan=arg
The desired minimum batch size. The default is "3", meaning less than 3, e.g. any sequence with a batch "size" set to 5 will display up to 7 items without creating a next batch.
overlap=arg
The number of rows to overlap between batches, default none.
previous
If the previous attribute is included, then iterative insertion will not be performed. The text following the in tag will be inserted and batch processing variables associated with information about a previous batch will be made available.
next
The next attribute has the same meaning and use as the previous attribute except that variables associated with the next batch are provided.
sequence
sequence-item[-even|-odd]
The current item in a sequence. -even|-odd Specifies whether the sequence item is even or odd. The variables will contain true or false respectively.
sequence-key[-even|-odd]
The key associated with the element in an items sequence. An items sequence is a sequence of value pairs that represent a mapping from a key to a value. -even|-odd Specifies whether the sequence key is even or odd. The variables will contain true or false respectively.
sequence-index[-var-xxx]
The index, starting from 0, of the element within the sequence. -var-xxx where -xxx is an element attribute name or key. This will display the value of the variable xxx in each iteration.
sequence-number
1, 2, 3, 4, 5
sequence-roman
i, ii, iii, iv, v
sequence-Roman
I, II, III, IV, V
sequence-letter
a, b, c, d, e
sequence-Letter
A, B, C, D, E
sequence-var-nnn
Each one of these variables has an associated variable name -var-nnn where nnn is an element attribute name or key.
Example:
<dtml-in sequence-query-var-id></dtml-in>
Summary
total-nnn
The total of numeric values.
count-nnn
The total number of non-missing values.
min-nnn
The minimum of non-missing values.
max-nnn
The maximum of non-missing values.
median-nnn
The median of non-missing values.
mean-nnn
The mean of numeric values.
variance-nnn
The variance of numeric values computed with a degrees of freedom equal to the (count - 1).
variance-n-nnn
The variance of numeric values computed with a degrees of freedom equal to the count.
standard-deviation-nnn
The standard deviation of numeric values computed with a degrees of freedom equal to the (count - 1).
standard-deviation-n-nnn
The standard deviation of numeric values computed with a degrees of freedom equal to the count.
Grouping
first-nnn
True if the current item is the first item among the displayed items that has the current value for variable, nnn ; False otherwise.
last-nnn
True if the current item is the last item among the displayed items that has the current value for variable, nnn ; False otherwise.
Batch Processing
sequence-start
This is useful when text must be inserted at the beginning of an dtml-in tag, especially if the text refers to any variables defined by the dtml-in tag.
sequence-end
The variable is true if the element being displayed is the last of the displayed elements, and false otherwise. This is useful when text must be inserted at the end of an dtml-in tag, especially if the text refers to any variables defined by the dtml-in tag.
sequence-query
The original query string given in a get request with the form variable named in the start attribute removed.
sequence-step-size
The batch size used.
sequence-step-start-index
???
sequence-step-end-index
???
previous-sequence
The variable is true when the first element is displayed, and when the first element displayed is not the first element in the sequence.
previous-sequence-start-index
The index, starting from 0, of the start of the batch previous to the current batch.
previous-sequence-end-index
The index, starting from 0, of the end of the batch previous to the current batch.
previous-sequence-size
The size of the batch previous to the current batch.
previous-batches
A sequence of mapping objects containing information about all of the batches prior to the batch being displayed.
next-sequence
The variable is true when the last element is displayed, and when the last element displayed is not the last element in the sequence.
next-sequence-start-index
The index, starting from 0, of the start of the batch after the current batch.
next-sequence-end-index
The index, starting from 0, of the end of the batch after the current batch.
next-sequence-size
The size of the batch after the current batch.
next-batches
A sequence of mapping objects containing information about all of the batches after the batch being displayed.
batch-start-index
The index, starting from 0, of the beginning of the batch.
batch-end-index
The index, starting from 0, of the end of the batch.
batch-size
The size of the batch.

with /with

Expand the namespace of a document template by adding attributes or mapping keys from an object which already exists in the document template namespace.


only
Prunes enclosing namespaces, use this to prevent acquisition within a DTML with tag.

let

Similar to with "_.namespace()", multiple assignments. Limited scope.


call

Elvaluate without including any returned value.

raise /raise

Raises a Python-like Error. It also causes any changes made by a web request to be ignored, if they occurred within transactional persistence mechanism.

try [except]* /try

Error handling (Python class-based exceptions). Used to avoids returning a Zope error message and continue rendering.

tag

Generates an HTML Image tag with an absolute url.

comment /comment

excludes source from being rendered and returns an HTML comment.

tree /tree

Display Zope objects hierarchically.


name=arg
See general tag.
expr=arg
See general tag.
branches=arg
The name of the method used to find sub-objects. This defaults to tpValues, which is a method defined by a number of objects in Zope and in Zope products.
branches_expr=arg
An expression which is evaluated to find sub-objects. This attribute performs the same function as the branches attribute but uses an expression rather than the name of a method.
id=arg
The name of a method or attribute used to determine the id of an object for the purposes of calculating tree state. This defaults to tpId which is a method defined by many Zope objects. This attribute is mostly useful for developers who wish to have fine control of the internal representation of the tree state.
url=arg
The name of a method or attribute used to determine the url of an object. This defaults to tpURL which is a method defined by many Zope objects. This attribute is mostly useful for developers who wish to have fine control over tree url generation.
leaves=arg
The name of a Document used to expand sub-objects that do not have sub-object branches.
header=arg
The name of a Document to be shown at the top of each expansion. This provides an opportunity to "brand" a branch in a hierarchy. If the named document cannot be found for a branch, then the header attribute is ignored for that branch.
footer=arg
The name of a Document to be shown at the bottom of each expansion. If the named document cannot be found for a branch, then the footer attribute is ignored for that branch.
nowrap=arg
Either 0 or 1. If 0, then branch text will wrap to fit in available space, otherwise, text may be truncated. The default value is 0.
sort=arg
Sort branches before text insertion is performed. The attribute value is the name of the attribute that items should be sorted on.
assume_children=arg
Either 0 or 1. If 1, then all items are assume to have sub-items, and will therefore always have a plus sign in front of them when they are collapsed. Only when an item is expanded will sub-objects be looked for. This could be a good option when the retrieval of sub-objects is a costly process.
single=arg
Either 0 or 1. If 1, then only one branch of the tree can be expanded. Any expanded branches will collapse when a new branch is expanded.
skip_unauthorized=arg
Either 0 or 1. If 1, then no errors will be raised trying to display sub-objects to which the user does not have sufficient access.
variables set by tree tag
tree-item-expanded
True is the current item is expanded.
tree-item-url
The URL of the current item relative to the URL of the DTML document in which the tree tag appears. This variable relies on the tree tag's url attribute to generate the tree-item URL.
tree-root-url
The URL of the DTML document in which the tree tag appears.
tree-level
The depth of the current item. Items at the top of the tree have a level of 0.
tree-colspan
The number of levels deep the tree is being rendered. This variable along with the tree-level variable can be used to calculate table rows and colspan settings when inserting table rows into the tree table.
tree-state
The tree state expressed as a list of ids and sub-lists of ids. This variable is mostly of interest to developers who which to have precise knowledge of a tree's state.
Variables that influence the tree tag
expand-all
If set to a true value, this variable causes the entire tree to be expanded.
collapse-all
If set to a true value, this variable causes the entire tree to be collapsed.
tree-s
This variable contains the tree state in a compressed and encoded form. This variable is set in a cookie to allow the tree to maintain its state. Developers may control the state of the tree directly by setting this variable, though this is not recommended.
tree-e
This variable contains a compressed and encoded list of ids to expand. Developers may control the state of the tree directly by setting this variable, though this is not recommended.
tree-c
This variable contains a compressed and encoded list of ids to collapse. Developers may control the state of the tree directly by setting this variable, though this is not recommended.

sqlvar

The sqlvar tag is used to type-safely insert values into SQL text. The sqlvar tag is similar to the var tag, except that it replaces text formatting parameters with SQL type information.
name
The name of the variable to insert. The name= prefix is usually omitted.
type
Required. The data type of the value to be inserted: string, int, float, or nb. nb indicates a string that must have a length that is greater than 0.
optional
Optional flag. If a value has this flag and is not provided or is blank then the string null is inserted.

sqltest

The sqltest tag is used to insert SQL source to test whether an SQL column is equal to a value given in a DTML variable.
name
The name of the variable to insert. The name= prefix is usually omitted.
type
Required. The data type of the value to be inserted: string, int, float, or nb. nb indicates a string that must have a length that is greater than 0.
column
The name of the SQL column, if different than name.
multiple
A flag indicating whether multiple values may be provided.
optional
Optional flag. If a value has this flag and is not provided or is blank then the string null is inserted.

sqlgroup

The sqlgroup tag checks to see if text to be inserted contains other than whitespace characters. If it does, then it is inserted with the appropriate boolean operator, as indicated by use of an 'and' or 'or' tag, otherwise, no text is inserted.
required
The required attribute is used to flag groups that must include at least one test. This is useful when you want to make sure that a query is qualified, but want to be very flexible about how it is qualified.
where
The where flag is used to cause an sql "where" to be included if a group contains any text. This attribute is useful for queries that may be either qualified or unqualified.

sendmail /sendmail

The sendmail tag is used to send an electronic message using the Simple Mail Transport Protocol (SMPT). Unlike other DTML tags, the sendmail tag does not cause any text to be included in output.


mailhost
A Zope MailHost object that manages Simple Mail Transport Protocol (SMTP) and port information. This attribute is not used if the smtphost attribute is used.
smtphost
The address of a SMTP server. Mail will be delivered to this server, which will do most of the work of sending mail. This attribute is not used if the mailhost attribute is used.
port
If the smtphost attribute is used, then the port attribute is used to specify a port number to connect to. If not specified, then port 25 will be used.
mailto
A recipient address or a list of recipient addresses separated by commas.
mailfrom
A sender address.
subject
The subject of the message.

mime

The mime tag is used in conjunction with the sendmail tag to send attachments along with electronic mail messages. See the README in Products/MIMETools for examples and exact hehavior.
boundary
The boundary tag is used within the mime tag to include multipart attachments. It accepts the same arguments as the mime tag.
type
Sets the MIME header, Content-Type, of the subsequent data.
disposition
Sets the MIME header, Content-Disposition, of the subsequent data. If disposition is not specified in a mime or boundary tag, then Content-Disposition MIME header is not included.
encode
Sets the MIME header, Content-Transfer-Encoding, of the subsequent data. If encode is not specified, base64 is used as default. The options for encode are: base64, quoted-printable, uuencode, x-uuencode, uue, x-uue, and 7bit. No encoding is done if set to 7bit.

_ (special namespace variable)

General Attributes
abs(X)
Return the absolute value of a number.
chr(I)
Return a string of one character whose ASCII code is integer I , e.g., chr(97) returns the string 'a' . This is the inverse of ord() . The argument must be in the range 0-255, inclusive.
DateTime()
Create a DateTime object from zero or more arguments. See Object Reference DateTime.
divmod(A,B)
Take two numbers as arguments and return a pair of integers consisting of their integer quotient and remainder. With mixed operand types, the rules for binary arithmetic operators apply. For integers, the result is the same as (A/B,A%B). For floating point numbers the result is the same as (math.floor(A/B),A%B).
float(X)
Convert a number to floating point. The argument may be a plain or long integer or a floating point number.
getattr(O,name)
Get the named attribute from an object.
hasattr(O,name)
Test whether the name can be found in the namespace.
getitem(name,flag)
Lookup a name in the namespace. If the value is callable and the flag is true, then the result of calling the value is returned, otherwise the value is returned. flag defaults to false.
hash(O)
Return the 32-bit integer hash value of the object.
hex(X)
Convert an integer to a hexadecimal string.
int(X)
Convert a number to an integer.
len(S)
Return the length (the number of items) of a collection of items.
math
The math module (table See Attributes defined by the math module), which defines mathematical functions.
max(S)
Return the largest item of a non-empty sequence.
min(S)
Return the smallest item of a non-empty sequence.
namespace(name1=value1,name2=value2, ...)
The namespace function can be used with the in tag to assign variables for use within a section of DTML. The function accepts any number of "keyword" arguments, which are given as name=value pairs.
None
A special value that means "nothing".
oct(X)
Convert an integer.
ord(C)
Return the ASCII value of a string of one character. E.g., ord('a') returns the integer 97 . This is the inverse of chr() .
pow(X,Y)
Return X to the power Y . The arguments must have numeric types. With mixed operand types, the rules for binary arithmetic operators apply. The effective operand type is also the type of the result; if the result is not expressible in this type, the function raises an exception, e.g. pow(2,-1) and pow(2,35000) raise exceptions.
random
The random module (See: random attributes), which defines various random-number generating functions.
round(X,N)
Return the floating point value X rounded to N digits after the decimal point. If N is omitted, the default value is 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 equally close, rounding is done away from 0 (so e.g. round(0.5) is 1.0 and round(-0.5) is -1.0 ).
str(O)
Return a string containing a representation of an object.
string
The string module (table See Attributes defined by the string module), which defines string functions.
whrandom
The whrandom module (See: whrandom attributes), which defines random-number generating functions using the Wichmann-Hill pseudo-random number generator.
Math module attributes
acos(X)
Compute the inverse cosine, in radians, of X.
asin(X)
Compute the inverse sine, in radians, of X.
atan(X)
Compute the inverse tangent, in radians, of X.
atan2(X)
Compute the inverse tangent, in radians, of the quotient of X and Y.
ceil(X)
Return the smallest integer that is greater than X.
cos(X)
Compute the cosine of X, which is in radians.
cosh(X)
Compute the hyperbolic cosine of X.
e
The base of the natural logarithms.
exp(X)
Compute the exponential function of X, or e to the power X, where e is the base of the natural logarithms.
fabs(X)
Compute a floating-point absolute value of the number, X.
floor(X)
Return the largest integer less than X.
fmod(X)
Return the remainder of the division of X by Y.
frexp(X)
Return the mantissa and exponent in base 2 of the floating-point value of X, such that absolute value mantissa is between 0.5 and 1.0 or is 0.
hypot(X)
Compute the hypotenuse of a right triangle with sides X and Y.
ldexp(X)
Return X times two to the power of Y.
log(X)
Compute the natural (base e) logarithm of X.
log10(X)
Compute the common (base 10) logarithm of X.
modf(X)
Break a number into its whole and fractional parts.
pi
The mathematical constant, pi
pow(X, Y)
Raise X to the power Y.
sin(X)
Compute the sine of X.
sinh(X)
Compute the sine of X.
sqrt(X)
Compute the square-root of X.
tan(X)
Compute the tangent of X.
tanh(X)
Compute the hyperbolic tangent of X.
random module attributes
betavariate (alpha, beta)
Beta distribution. Conditions on the parameters are alpha >- 1 and beta > -1. Returned values will range between 0 and 1.
choice(seq)
Choose a random element from the non-empty sequence seq and return it.
cunifvariate(mean, arc)
Circular uniform distribution. mean is the mean angle, and arc is the range of the distribution, centered around the mean angle. Both values must be expressed in radians, and can range between 0 and *. Returned values will range between mean - arc/2 and mean + arc/2.
expovariate(lambd)
Exponential distribution. lambd is 1.0 divided by the desired mean. (The parameter would be called "lambda", but that is a reserved word in Python.) Returned values will range from 0 to positive infinity.
gamma(alpha, beta)
Gamma distribution. (Not the gamma function!) Conditions on the parameters are alpha > -1 and beta > 0.
gauss(mu, sigma)
Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate() function defined below.
lognormvariate(mu, sigma)
Log normal distribution. If you take the natural logarithm of this distribution, you'll get a normal distribution with mean mu and standard deviation sigma. mu can have any value, and sigma must be greater than zero.
normalvariate(mu, sigma)
Normal distribution. mu is the mean, and sigma is the standard deviation.
paretovariate(alpha)
Pareto distribution. alpha is the shape parameter.
randint(a, b)
Return a random integer N, such that a<=N<=b
random()
Return a random real number N, such that 0<=N<1.
uniform(a, b)
Return a random real number N, such that a<=N
vonmisesvariate(mu, kappa)
mu is the mean angle, expressed in radians between 0 and pi, and kappa is the concentration parameter, which must be greater then or equal to zero. If kappa is equal to zero, this distribution reduces to a uniform random angle over the range 0 to pi. (I'm assuming pi, the DTML guide was blank?)
weibullvariate(alpha, beta)
Weibull distribution. alpha is the scale parameter and beta is the shape parameter.
string module attributes
digits
The string '0123456789'.
hexdigits
The string `0123456789abcdefABCDEF'.
letters
The concatenation of the strings lowercase' and uppercase' described below.
lowercase
A string containing all the characters that are considered lowercase letters. On most systems this is the string `abcdefghijklmnopqrstuvwxyz'.
octdigits
The string `01234567'.
uppercase
A string containing all the characters that are considered uppercase letters. On most systems this is the string `ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
whitespace
A string containing all characters that are considered "white space". On most systems this includes the characters space, tab, line feed, return, form feed, and vertical tab.
atof(X)
Convert a string to a floating point number.
atoi(S[,BASE])
Convert string S to an integer in the given BASE. The string must consist of one or more digits, optionally preceded by a sign (+' or -'). The BASE defaults to 10. If the base is 0, a default base is chosen depending on the leading characters of the string (after stripping the sign): '0x' or '0X' means 16, '0' means 8, anything else means 10. If BASE is 16, a leading '0x' or '0X' is always accepted.
capatilize(W)
Capitalize the first character of the argument.
capwords(S)
Convert sequences of spaces, tabs, new-line characters, and returns to single spaces and convert every lower-case letter at the beginning of the string or that follows space to an uppercase letter.
find(S, SUB[,START])
Return the lowest index in S not smaller than START where the sub-string SUB is found. Return -1 when SUB does not occur as a sub-string of S with index at least START. If START is omitted, the default value is 0. If START is negative, then it is added to the length of the string.
rfind(S, SUB[,START])
Like find but find the highest index.
index(S, SUB[,START])
Like find but raise a ValueError exception when the substring is not found.
rindex(S, SUB[,START])
Like rfind but raise ValueError exception when the substring is not found.
count(S, SUB[,START])
Return the number of (non-overlapping) occurrences of substring SUB in string S with index at least START. If START is omitted, the default value is 0. If START is negative, then it is added to the length of the string.
lower(S)
Convert letters to lower case.
maketrans(FROM, TO)
Return a translation table suitable for passing to string.translate, that will map each character in FROM into the character at the same position in TO; FROM and TO must have the same length.
split(S [,SEP [,MAX]])
Return a list of the words of the string S. If the optional second argument SEP is absent or None, the words are separated by arbitrary strings of white-space characters (space, tab, new line, return, form feed). If the second argument SEP is present and not None, it specifies a string to be used as the word separator. The returned list will then have one more item than the number of non-overlapping occurrences of the separator in the string. The optional third argument MAX defaults to 0. If it is nonzero, at most MAX number of splits occur, and the remainder of the string is returned as the final element of the list (thus, the list will have at most MAX+1 elements).
join(WORDS[,SEP])
Concatenate a list or tuple of words with intervening occurrences of SEP. The default value for SEP is a single space character. It is always true that string.join(string.split(S, SEP), SEP) equals S.
lstrip(S)
Remove leading white space from string S.
rstrip(S)
Remove trailing white space from string S
strip(S)
Remove leading and trailing white space from string S.
swapcase(S)
Convert lower case letters to upper case and vice versa.
translate(S, TABLE[,DELS]
Delete all characters from S that are in DELS (if present), and then translate the characters using TABLE, which is a 256-character string giving the translation for each character value, indexed by its ordinal.
upper(S)
Convert letters to upper case.
ljust(S, WIDTH)
These functions respectively left-justify, right-justify and center a string in a field of given width. They return a string that is at least WIDTH characters wide, created by padding the string S with spaces until the given width on the right, left or both sides. The string is never truncated.
rjust(S, WIDTH)
See ljust(S, WIDTH).
center(S, WIDTH)
See ljust(S, WIDTH).
zfill(S, WIDTH)
Pad a numeric string on the left with zero digits until the given width is reached. Strings starting with a sign are handled properly.
whrandom module attributes


choice(seq)
Choose a random element from the non-empty sequence seq and return it.
randint(a, b)
Return a random integer N, such that a<=N<=b.
random()
Return a random real number N, such that 0<=N<1.
seed(X, Y, Z)
Initialize the random number generator from the integers X, Y and Z.
uniform(a, b)
Return a random real number N, such that a<=N

Zope-defined Web request variables

AUTHENTICATED_USER
An object that represents an authenticated user. When inserted into a DTML document, the value is the user name. This object currently provides no public attributes. Note that this variable may not be defined in Documents that are not protected by security information.


has_role(self, roles, [object])
Check to see if a has a given role or roles.
has_permission(self, permission, object)
Check to see if a user has a given permission on an object.
getDomains(self)
Returns a list of domain restrictions for a user.
getRoles(self)
Returns a list of roles assigned to a user.
getUserName(self)
Returns the name of the current user
AUTHENTICATION_PATH
The path to the object containing the user database folder which contained the definition for the authenticated user.
PARENTS
A sequence of ancestors of the object that was accessed in the current request. For example, if the accessed object is a Document, then PARENTS[0] is the folder containing the document, PARENTS[1] is the folder containing the folder containing the document, and so on.
REQUEST
An object that represents the current request. This object may be used in an expr expression to look up request data, including variables described in this table, CGI-defined variables (table See CGI-defined Web request variables), form variables, cookies, and HTTP headers. In addition, expr expressions may use the following request attributes.
cookies
If an HTTP Cookie was included in the request, then this attribute is a dictionary containing the cookie data. This allows cookie data to be looked up, even if a cookie name is the same as a form variable or an object attribute name.
form
If a request was initiated by submitting a form, then the form attribute is a dictionary object, containing the form data. This allows form data to be looked up, even if a form name is the same as an object attribute name.
has_key(name)
Determine whether the REQUEST defines a given name.
set(name, value)
Set a variable in the request.
RESPONSE
An object that represents the response to the current request. This object is primarily useful in expr expressions using the following attributes.
setStatus(status)
Set the HTTP status code of the response; the argument may either be an integer or a string from {Created, Accepted, NoContent, MovedPermanently, MovedTemporarily, NotModified, BadRequest, Unauthorized, Forbidden, NotFound, InternalError, NotImplemented, BadGateway, ServiceUnavailable} that will be converted to the correct integer value.
setHeader(name, value)
Set an HTTP return header name with value value , clearing the previous value set for the header, if one exists.
getStatus()
Return the current HTTP status code as an integer.
setBase(base)
Set the base URL for the returned document.
expireCookie(name)
Cause an HTTP cookie to be removed from the browser The response will include an HTTP header that will remove the cookie corresponding to "name" on the client, if one exists. This is accomplished by sending a new cookie with an already passed expiration date.
setCookie(name, value, ...)
Cause the response to include an HTTP header that sets a cookie on cookie-enabled browsers with a key name and value value. This overwrites any previously set value for the cookie in the Response object. Additional cookie parameters can be included by supplying keyword arguments. The valid cookie parameters are expires, domain, path, max_age, comment, and secure.
getHeader(name)
Return the value associated with an HTTP return header or None if no such header has been set in the response.
appendHeader(name, value)
Set an HTTP return header "name" with value "value" and appending it following a comma if there is a previous value set for the header.
redirect(location)
Cause a redirection without raising an error.
set(name, value)
Set a variable in the request.
URL
The URL used to invoke the request without the query string, if any.

CGI-defined Web request variables

SERVER_SOFTWARE
The name and version of the information server software answering the request. Format: name/version
SERVER_NAME
The server's host name, DNS alias or IP address as it would appear in self-referencing URLs.
GATEWAY_INTERFACE
The revision of the CGI specification to which this server complies. Format: CGI/revision.
SERVER_PROTOCOL
The name and revision of the information protcol this request came in with. Format: protocol/revision
SERVER_PORT
The port number to which the request was sent.
REQUESTED_METHOD
The method with which the request was made. For HTTP, this is "GET", "HEAD", "POST", etc.
PATH_INFO
The part of the request URL, not counting the query string, following the name of the Zope installation or module published by ZPublisher.
PATH_TRANSLATED
The server provides a translated version of PATH_INFO, which takes the path and does any virtual-to-physical mapping to it.
SCRIPT_NAME
A virtual path to the script being executed, used for self-referencing URLs.
QUERY_STRING
The information which follows the ? in the URL which referenced this script. This is the query information.
REMOTE_HOST
The host name making the request. If the server does not have this information, it should REMOTE_ADDR and leave REMOTE_HOST unset.
REMOTE_ADDR
The IP address of the remote host making the request.
AUTH_TYPE
If the server supports user authentication, and the script is protected, this is the protocol-specific authentication method used to validate the user.
REMOTE_USER
If the server supports user authentication, and the script is protected, this is the username under which it has been authenticated.
REMOTE_IDENT
If the HTTP server supports RFC 931 identification, then this variable will be set to the remote username retrieved from the server. Usage of this variable should be limited to logging only.
CONTENT_TYPE
For queries which have attached information, such as HTTP POST and PUT, this is the content type of the data.
CONTENT_LENGTH