Changes between Initial Version and Version 1 of S3/S3Request

10/22/10 11:21:01 (11 years ago)
Dominic König



  • S3/S3Request

    v1 v1  
     2= S3XRC - S3Request =
     4  - [wiki:S3XRC]
     6== S3Request and Method Handlers ==
     8When method handlers are called by the [wiki:S3XRC_S3Resource#RESTInterface REST interface], they get a S3Request object passed as the first argument, usually named "r" or "jr":
     11def method_handler(r, **attr):
     14This S3Request instance represents the request to be executed, and it contains references to all data necessary to perform the requested action.
     16  ''Note: All method handlers receive the same list of arguments, regardless of whether they are standard CRUD or custom method handlers.''
     17== Attributes of the S3Request ==
     19The following attributes are set during initialisation of an S3Request object, no further call is required.
     21=== Controller Attributes ===
     23||'''rc'''||the resource controller object (''S3ResourceController'')||
     24||'''request'''||the original web2py request (''Storage'')||
     25||'''session'''||the current session (''Storage'')||
     26||'''response'''||the web2py response (''Storage'')||
     28=== Request Attributes ===
     30||'''representation'''||the current representation of this request (''string'', lowercase)||
     31||'''http'''||the HTTP method of this request (''string'', always uppercase!)||
     32||'''extension'''||the extension found in the original request (''string'', lowercase)||
     33||'''method'''||the method of the request if not HTTP (''string'', always lowercase)||
     34||'''custom_action'''||the custom method handler for the request (''function'' or ''lambda'')||
     36=== Primary Resource Attributes ===
     38||'''prefix'''||the prefix (=module name) of the requested resource (''string'')||
     39||'''name'''||the name of the requested resource, without prefix (''string'')||
     40||'''tablename'''||the name of the primary table (''string'')||
     41||'''table'''||the primary table (''Table'')||
     42||'''id'''||the ID of the primary record (''int'')||
     43||'''record'''||the primary record (''Row'')||
     45=== Component Resource Attributes ===
     47||'''component'''||the requested component, if any (''!ObjectComponent'')||
     48||'''pkey'''||the primary key of the Resource/Component join (''string'')||
     49||'''fkey'''||the foreign key of the Resource/Component join (''string'')||
     50||'''component_name'''||the name of the component without prefix (''string'')||
     51||'''component_id'''||the ID of the component record as of the request, if any (''int'')||
     52||'''multiple'''||Flag indicating that multiple component records are allowed (''boolean'')||
     54=== Error Indicators ===
     56||'''error'''||the last error message (''string'')||
     57||'''invalid'''||Flag indicating this request as invalid (''boolean'')||
     58||'''badmethod'''||Flag indicating a bad method error (''boolean'')||
     59||'''badrecord'''||Flag indicating a invalid record ID error (''boolean'')||
     60||'''badrequest'''||Flag indicating an unqualified request error (''boolean'')||
     62'''!ObjectComponent''' contains:
     63  - '''prefix''', '''name''', '''tablename''', '''table''' and '''attr''' of the component
     64  - '''attr''' contains:
     65    - '''multiple''' Multiple-flag
     66    - '''editable''', '''deletable''' and '''listadd'''
     67    - '''list_fields''', '''rss''', '''main''' and '''extra'''
     68    - '''onaccept''', '''onvalidation''', '''delete_onaccept''' and '''delete_onvalidation'''
     69  - methods: '''set_attr()''' and '''get_attr()'''
     71== Methods of the S3Request ==
     73=== Magic URLs ===
     76  - returns the URL of the current request
     79  - returns the URL of a HTTP GET request for the same resource
     82  - returns the URL of the current request with the primary record ID replaced by the string literal '[id]'
     84'''other(method=None, record_id=None, representation=None)'''
     85  - returns the URL of a request with another method and record ID, but for the same resource
     87=== Other functions ===
     90  - returns the target table of the current request as tuple of (prefix, name, table, tablename)