Changes between Version 89 and Version 90 of S3/S3REST/s3_rest_controller


Ignore:
Timestamp:
09/09/21 10:37:55 (3 months ago)
Author:
Fran Boon
Comment:

Custom REST Controllers

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3REST/s3_rest_controller

    v89 v90  
    698698And...not to forget: your warehouse_report is still a controller function, that means you can implement forms as usual (e.g. operated with form.accepts or web2py Crud).
    699699
     700=== Re-Routing Controllers ===
     701There may be a time when you want to bypass the default controllers, or else add a custom controller which can have different options.
     702
     703This allows re-routing of any controller/function combination to the custom/rest controller - which is a vanilla s3_rest_controller, i.e. without any prep, postp or attr. The latter can then be added in customise_controller.
     704
     705To use this, a template will configure e.g.:
     706
     707{{{
     708settings.base.rest_controllers = {("org", "organisation"): ("org", "organisation")}
     709}}}
     710...which re-routes org/organisation to custom/rest, and runs it as a s3_rest_controller with prefix="org" and name="organisation". This re-routing is completely transparent, i.e. the s3_rest_controller (and anything called from there) sees a normal org/organisation request. Consequently, to customise this call, one would use customise_org_organisation_controller (not customise_custom_rest_controller!), as usual.
     711
     712As this allows re-routing of any controller/function combination, one can also "add" controllers that do not exist, e.g.:
     713
     714{{{
     715settings.base.rest_controllers = {("org", "suppliers"): ("org", "organisation")}
     716}}}
     717This would though still be customised via customise_org_organisation_controller (=>can inspect r.function in prep to distinguish), but page access authorisation would now be through org/suppliers rather than org/organisation (so can have different permissions for those).
     718
     719When adding a route with a custom module prefix:
     720
     721{{{
     722settings.base.rest_controllers = {("my", "organisation"): ("org", "organisation")}
     723}}}
     724...then a corresponding module entry for that must be added to settings.modules - though this is useful anyway if menus are to be added automatically etc. Again, page authorisation would go through my/organisation here instead of org/organisation, so there could be different permission sets.
     725
     726Note: this feature is orthogonal to default/index/*, which is still useful for implementing non-REST custom controllers, and should therefore be retained.
     727
    700728
    701729----