Previous Chapter | Next Chapter | Up | Next Section | Contents

Creating Search Interfaces


Database methods provide an interface between Zope and database queries. To publish data on the Web, Zope Documents must be created to collect input data, if necessary, and to display reports. Input forms and reports can be created from scratch, but is easier to use the Z search interface wizard to automatically create search interfaces. The search interface wizard collects basic information, such as the name of a database method and names of input and report documents to be created and then writes new documents based on database schema information. After the documents have been created with the search interface wizard, they can be customized by editing the documents created.

Figure See Search interface creation wizard shows the search interface creation wizard being used to create a search interface for the lookup_product database method. The first option in the form is a list of searchable objects found in the current folder, or in folders above the current folder. Searchable objects are objects, like Z SQL Database Methods , that support searching for information1. You can select one or more searchable objects to be included in the search interface. If you select multiple searchable objects, the generated input form will collect information needed for all objects, and the generated report will show results for each object, in sequence.

  1. Search interface creation wizard

 

Figure See Contents view of the Computer folder after adding a tabular search interface. shows the contents of the Computer folder after the form shown in figure See Search interface creation wizard has been submitted. The contents list includes two new documents, index_html, and tabular_product_report . By naming the input form index_html , we have created a "home page" for the Computer area that performs a product search. For example, if someone visited the URL: http://myhost/Plutonia/Computer, they would see the search input form shown in figure See An automatically generated input form for a tabular product search.

  1. Contents view of the Computer folder after adding a tabular search interface.

 

  1. An automatically generated input form for a tabular product search

 

The source of the generated input form is shown in figure See Source of the generated input form for the tabular product search. The input form is a Zope Document object and uses the DTML format.

  1. Source of the generated input form for the tabular product search

 

There are a number of features of the input form that should be noted:

See Output of a search using the tabular_product_report created by the search interface wizard. shows a the output of the tabular_product_report .

 

 

  1. The input form for a tabular product search, after adding a standard_html_header and a logo to the Computer folder.
  1. Output of a search using the tabular_product_report created by the search interface wizard.

The source of tabular_product_report is shown in figures See Part one of the source of the tabular_product_report document that was generated by the search-interface creation wizard. -See Part three of the tabular_product_report document, showing source to display following batches and text to be inserted when there are no results.. It is useful to walk through the generated document template source. The generated source illustrates a number important document template concepts and features of database methods. The section See Iterative Insertion, the in Tag in the Document Template User's guide provides a detailed description of document template in tags, including batch processing.

  1. Part one of the source of the tabular_product_report document that was generated by the search-interface creation wizard.

 

The source begins with the insertion of standard_html_header , as usual.

An in tag follows the insertion of standard header. The in tag is used to iterate over the results of calling the database method, lookup_product . The database method get's it's parameters from the incoming HTTP request, so parameters need not be passed explicitly2. The in tag uses the size and start attributes to request batch processing support3. This causes a number of special variables to be defined, which are used later in the in -tag source. These include previous-sequence , sequence-query , previous-sequence-start-number and previous-sequence-size .

Immediately after the in tag is an if tag that inserts text when the variable sequence-start is true, or, in other words, when displaying the first item in a batch of items. The inserted text includes a link to previous batches of data and a table header showing the data column names. The link to previous batches is inserted only if there are previous batches, as indicated by the previous-batches variable. The link uses the in tag variables sequence-query ,
previous-sequence-start-number , and previous-sequence-size .

After the table header is inserted, the actual data for each item in the batch is inserted (figure See Part two of the tabular_product_report Document, showing the DTML text to insert data items.).

  1. Part two of the tabular_product_report Document,
    showing the DTML text to insert data items.

 

The last part of the text following the in tag is text to insert a table closing tag and to show a link to additional batches of data, if any (figure See Part three of the tabular_product_report document, showing source to display following batches and text to be inserted when there are no results.). Two if tags are used to insert the text only when displaying the last item in a batch and to only include the link to following batches if there are any. Finally, the source ends with an else tag that inserts text if there are no results for the given inputs.

  1. Part three of the tabular_product_report document, showing source to display following batches and text to be inserted when there are no results.

 

After the search-interface creation wizard has been used to create report and input-form documents, the documents may be edited in the manner to meet specific needs.

 

Previous Chapter | Next Chapter | Up | Next Section | Contents