Previous Chapter | Next Chapter | Up | Next Section | Contents
Commonly, it is necessary to insert a sequence of values. Some objects, like Zope SQL Method s, and Confera Topics support searching and a means is needed for iterating over search results.
When creating input forms with select lists, it is sometimes a good idea to store the contents of the list in a folder property so that the list can be edited independently from the input form. In this case, the select list options are inserted into a form by iterating over the list property.
The in tag is used to iterate over a sequence of objects. For example, an employee directory listing might be created with DTML source like that shown in figure See DTML source to create an employee phone listing. In this example, employees is either a sequence of employees, or a function, such as an Zope SQL Method , that computes a sequence of employees. Each employee has a name and phone attribute. These attributes are accessed using var tags. An in tag's sort attribute is used to sort employees by name in the output. The in tag attributes are listed in table See in tag attributes.
in tag attributes |
||
Name | Needs an argument | Description |
---|---|---|
name | yes | Insert the name of the variable. See "The name attribute" on page 9. |
expr | yes | Insert an expression that evaluates the value. See The expr attribute" on page 9. |
mapping | no | 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. |
sort | yes | 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 | yes | The name of a (request) variable that specifies the number of the row on which to start a batch13. |
size | yes | The batch size. |
skip_unauthorized | no | 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 | yes | The desired minimum batch size. |
overlap | yes | The number of rows to overlap between batches. |
previous | no | 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 | no | The next attribute has the same meaning and use as the previous attribute except that variables associated with the next batch are provided. |
In the example, an empty table would be displayed if there were no employees. To avoid displaying an empty table a message can be provided indicating that there are no employee by using the in tag in combination with the if tag, as shown in figure See DTML source to create an employee phone listing which properly handles the case of no employees by using an in tag with an if tag.. In figure See DTML source to create an employee phone listing which properly handles the case of no employees by using an in tag with an if tag., the if tag is used with the employees variable. Sequences of objects are false if they are empty and true if they are not. If there are no employees, the condition in the if tag is false and the text following the else tag is inserted.
Previous Chapter | Next Chapter | Up
| Next Section | Contents
SUBSECTIONS