Previous Chapter | Up | Next Section | Contents

Create a database method


Database methods provide the mechanism for executing database queries and other commands and making the results available to Zope .

Figure See Form used to create a database method to retrieve part data. shows an input form for an SQL database method to retrieve parts data from the Plutonia Computer Inc. parts database. Note that the id of the parts database connection is specified. Because the database method requires input data, an argument, part_number is specified. The SQL used to perform the query is specified as a query template . Query templates use the same Document Template Markup Language ( DTML ) used to create Zope Documents . Query templates provide specialized tags for use in generating SQL. In this example, an sqltest tag is used to insert an SQL test that compares the column, part_no to a value given as input in the argument part_number. Figure See Output from the test form shown in figure 3 shows the SQL generated when an input part number, "fdax" is input to the template.

  1. Form used to create a database method to retrieve part data.

 

If we add and test the SQL method, an input form is displayed, as shown in figure See A test input form for the database method in figure 2. If we type in the part number, "fdax", and submit the query, the output of the query is displayed along with the SQL that was generated (figure See Output from the test form shown in figure 3).

 

 

  1. A test input form for the database method in figure See Form used to create a database method to retrieve part data.
  1. Output from the test form shown in figure See A test input form for the database method in figure 2

After a database method has been created, it must be tested, to:

A database method can be tested when it is created by clicking on the "Add and Test" button on the add form. A database method may be tested at any time by selecting it's test view.

After a database method has been created and tested, a search interface can be created to publish the data on the web. Creating a search interface is described in the section, See Creating Search Interfaces.

Previous Chapter | Up | Next Section | Contents