Changes between Version 30 and Version 31 of DeveloperGuidelinesS3Framework

02/03/10 12:23:35 (14 years ago)
Fran Boon

Plugin REST functions


  • DeveloperGuidelinesS3Framework

    v30 v31  
    1616We extend the CRUD with a [wiki:BluePrintRESTImplementation RESTlike controller].[[BR]]
    1717This provides details on how to configure your Model & Controllers. Views may not be required, other than index.html
     19==== Custom Functions Plugged into REST ====
     20In many cases it may be much easier to implement non-CRUD resource functions as REST-plugins instead of separate controllers.
     21 * see search_simple for an example
     23The advantage of doing it as REST plugin is that you have a pre-parsed XRequest instead of the original request, as well as you'd preserve the actions and setting from your REST interface for this resource.
     25XRequest is already checked and parsed for the REST syntax, and is resolved for the format extension (XRequest.representation) and record ID's, contains all handles to the necessary tables as well as the complete primary record (if any).
     27It contains the interface to export or import the resource in XML and JSON (.import_xml() and .export_xml() resp. _json()), and of course you'd have the nice backlink helpers to quickly produce URL's:
     29 .here() (=URL of the current resource),
     30 .same() (=URL of the current resource, record ID replaced as "[id]"),
     31 .there() (=URL of the current resource, no function, no record ID), and
     32 .other() (=URL of the current resource, other function)
     34and finally, XRequest remembers the record ID until the next request to the same resource in the same session, which can be helpful when producing links (especially _next's) not knowing the record ID.
    1936=== Mandatory ===