An SQL Database Method is created by selecting " Z SQL Database Method " in the add list of a Folder Contents view, after which an input form is presented (figure ). In addition to the standard Zope properties, id and title , three additional properties may be specified.
The required property, connection id is used to specify which database connection will be used by the database method. A Database Connection object must be created prior to creating an SQL Database Method . The database connection can be created in the current folder, or in any folder above the current folder. The connection list shown in the input form shows all connections that can be found in the current folder or in folders above the current folder.
The optional property, arguments , is used to specify one or more input arguments. Input arguments are used to customize a query based input data, such as data passed in a Web request, or in a DTML expr attribute. Multiple arguments are separated by one or more spaces or tab characters. Each argument is specified as an argument name, an optional argument type, and an optional argument default (figure See Database method input argument format. Argument name and type are separated by a colon. A equal sign separates the default value from the name and type. The default value is a string representation of the desired value. If the default value contains spaces, or is an empty string, then it must be surrounded by double quotes.). The argument name should consist of letters, underscores, and digits and should start with a letter. The type should be one of the values shown in table See Database-method input argument types. The default type is string . Table See Some sample database-method input arguments shows several examples of input arguments.
A date-time value. A wide variety of formats are accepted4. Year, months, and day cab be provided in any unambiguous order5. Month names and abbreviations of various forms may be provided. Hours minutes and seconds may are optional and are separated from the date by one or more spaces and from each other by colons. A 24-hour clock is assumed unless times are followed by am , AM , pm or PM . |
|
A list of values. This is useful to assure that a sequence of values is available when the query template uses an in tag to iterate over inputs. The list type may be combined with the int , float , and date types to specify a list of integers, floating-point numbers, and dates. |
|
A single input string is split on line endings into a list of one or more values. |
|
A single input string is split on sequences of one or more space, tab, new-line, or carriage-return characters into a list of values. |
|
A single input string in which sequences of new-line and carriage-return characters are converted to single newline characters. |
The query template is the source of the desired SQL query or commands in DTML format. DTML tags may be used to substitute text into a query based on input data and on information defined in Zope . See Query templates
Previous Chapter | Next Chapter | Up | Next Section | Contents