Version 4 (modified by Dominic König, 13 years ago) ( diff )


S3REST and XRequest


s3rest is a callable global object which implements the RESTful interface for the S3 framework.

s3rest is an instance of the RESTController class, implemented in modules/



rcthe resource controller object (S3XRC)
prefixthe prefix (=module name) of the requested resource (string)
namethe name of the requested resource, without prefix (string)
requestthe original web2py request (Storage)
sessionthe current session (Storage)
errorthe last error message (string)
invalidFlag indicating this request as invalid (boolean)
badmethodFlag indicating a bad method error (boolean)
badrecordFlag indicating a invalid record ID error (boolean)
badrequestFlag indicating an unqualified request error (boolean)
representationthe current representation of this request (string, lowercase)
httpthe HTTP method of this request (string, always uppercase!)
extensionthe extension found in the original request (string, lowercase)
tablenamethe name of the primary table (string)
tablethe primary table (Table)
methodthe method of the request if not HTTP (string, always lowercase)
idthe ID of the primary record (int)
recordthe primary record (Row)
componentthe requested component, if any (ObjectComponent)
pkeythe primary key of the Resource/Component join (string)
fkeythe foreign key of the Resource/Component join (string)
component_namethe name of the component without prefix (string)
component_idthe ID of the component record as of the request, if any (int)
multipleFlag indicating that multiple component records are allowed (boolean)
custom_actionthe custom method handler for the request (function or lambda)

ObjectComponent contains:

  • prefix, name, table_name, table and attr of the component
  • attr contains:
    • multiple Multiple-flag
    • editable, deletable and listadd
    • list_fields, rss, main and extra
    • onaccept, onvalidation, delete_onaccept and delete_onvalidation
  • methods: set_attr() and get_attr()



  • returns the URL of the current request


  • returns the URL of a HTTP GET request for the same resource


  • returns the URL of the current request with the primary record ID replaced by the string literal '[id]'

other(method=None, record_id=None, representation=None)

  • returns the URL of a request with another method and record ID, but for the same resource


  • returns the target table of the current request as tuple of (prefix, name, table, tablename)

export_xml(permit=None, audit=None, template=None, filterby=None, pretty_print=False)

  • exports the requested resources as XML

export_json(permit=None, audit=None, template=None, filterby=None, pretty_print=False)

  • exporta the requested resources as JSON

import_xml(tree, permit=None, audit=None, onvalidation=None, onaccept=None)

  • import the requested resources from the given ElementTree


  • export the options of a field in the resource as XML


  • export the options of a field in the resource as JSON

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.