wiki:S3/S3Request

Version 2 (modified by Dominic König, 11 years ago) ( diff )

--

S3XRC | S3 RESTful API | S3Request

S3Request Class

Attributes of S3Request

The following attributes are set during initialisation of an S3Request object, no further call is required.

Environment

requestthe original web2py request (Storage)
sessionthe current session (Storage)
responsethe web2py response (Storage)

Request Attributes

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)
methodthe method of the request if not HTTP (string, always lowercase)
custom_actionthe custom method handler for the request (function or lambda)

Primary Resource Attributes

resourcethe target resource of the request (S3Resource)
prefixthe prefix (=module name) of the requested resource (string)
namethe name of the requested resource, without prefix (string)
tablenamethe name of the primary table (string)
tablethe primary table (Table)
idthe ID of the primary record (int)
recordthe primary record (Row)

Component Resource Attributes

componentthe requested component, if any (!S3ResourceComponent)
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)

!S3ResourceComponent contains:

  • prefix, name, tablename, table and attr of the component
  • attr contains:
    • multiple Multiple-flag
  • methods: set_attr() and get_attr()

Methods of the S3Request

Magic URLs

here(representation=None)

  • returns the URL of the current request

there(representation=None)

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

same(representation=None)

  • 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

Other functions

target()

  • returns the target table of the current request as tuple of (prefix, name, table, tablename)
Note: See TracWiki for help on using the wiki.