Version 15 (modified by Fran Boon, 13 years ago) ( diff )


BluePrint: RESTful Search Methods


  • coming soon


  • coming soon


  • coming soon


Functional Requirements

  • tbd

Usability Requirements

  • tbd

Performance Requirements

  • tbd

Implementation Requirements

  • tbd


User Interface

  • add mockups here



REST Interface

The S3Find class implements the S3Method interface, and is connected to the search URL method in s3_rest_controller:


S3Find implements both interactive and non-interactive search methods. Currently supported formats are:

  • HTML
  • JSON

There is a generic S3Find default instance connected to all resources, which will be used unless there is a resource-specific instance configured. However, this default instance does not provide any interactive search methods (JSON only).

To connect a custom S3Find instance to a resource (in order to add interactive search methods), use s3xrc.model.configure:

s3xrc.model.configure(table, search_method=my_s3find_instance

See the next paragraph for how to build and connect a custom S3Find instance for a resource.

Configuring Interactive search methods

For interactive search, a custom S3Find instance can be configured per resource, using instances of classes implementing the S3SearchWidget interface to create search forms.

Note: Since neither S3Find nor S3SearchWidgets actually contain any link to a particular resource, their instances can be re-used across multiple resources, as long as the search fields are the same.

Two interactive search forms can be configured (both of which are optional): simple and advanced, where the user can toggle between these forms (if both are defined).

    # Use a variable to hold the S3Find instance
    hms_hospital_search = s3base.S3Find(

        # Simple search form as a tuple of widgets:
                  # simple full-text search widget:
                    name="hospital_search_advanced",             # widget name must be specified and unique in the form!
                    label=T("Name and/or ID"),                   # Label for the search field
                    comment=T("To search for a hospital, ..."),  # Tooltip text for the search field
                    field=["paho_uuid",                          # Names of fields to search in
                  ), # <-- note the comma!

        # Advanced search form as a tuple of widgets:

                  # simple full-text search widget:
                    label=T("Name, Org and/or ID"),
                    comment=T("To search for a hospital, ..."),
                           "",                       # "." separator: search in component
                           "organisation_id$name",               # "$" separator: search in records referenced by organisation_id

                  # MinMax search widget to filter for a range of values:
                    method="range",                              # widget-specific attribute "method"
                    label=T("Total Beds"),
                    comment=T("Select a range for the ..."),
                    field="total_beds"                           # most widgets only support one search field

    # Set as standard search method for this resource
    s3xrc.model.configure(db.hms_hospital, search_method=hms_hospital_search)

The simple form usually consists of a S3SearchSimpleWidget which performs a simple full-text search through various fields of the resource. However, the simple form may also be configured with other search widgets. In the same manner, the advanced form can include the S3SearchSimpleWidget.

When calling the search method, the simple form will be opened first, while the advanced form is hidden (if only the advanced form is defined, then it will of course not be hidden). By clicking the Advanced Search link below the form, the user can switch to the advanced form, and vice versa. The forms are independent, i.e. the user can only submit one of them.

  • modules/s3/


  • tbd
  • tbd
  • tbd
  • tbd

S3Search Subclasses

  • tbd
  • tbd


Note: See TracWiki for help on using the wiki.