Changes between Version 8 and Version 9 of DeveloperGuidelines/Tutorial/RESTCustomisation


Ignore:
Timestamp:
06/11/10 21:24:40 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Tutorial/RESTCustomisation

    v8 v9  
    111111  - '''!http://site.myserver.org/eden/wm/warehouse/report.xml'''
    112112
    113 How to tackle this?
    114 
    115 Yes - you can use shn_rest_controller for this!
    116 
    117 This could be your "warehouse" controller:
     113How to tackle this? Yes - you can use shn_rest_controller for this!
     114
     115This could be your "warehouse" CRUD controller:
    118116
    119117{{{
    120118def warehouse():
     119
    121120   """ RESTful CRUD controller """
     121
    122122   return shn_rest_controller(module, resource, ...)
    123123}}}
     
    127127{{{
    128128def warehouse():
    129     """ RESTful CRUD controller """
     129
     130    """ RESTful CRUD+Reports controller """
     131
     132    # Plug warehouse_report into warehouse resource:
    130133    s3xrc.model.set_method(module, resource, method="report", action=warehouse_report)
     134
    131135    return shn_rest_controller(module, resource, ...)
    132136
    133137def warehouse_report(jr, **attr):
    134     """" Warehouse report """
    135     <Code to produce the report>
     138
     139    """ Warehouse report generator """
     140
     141    # Code to produce the report goes here
     142    report = ...
     143
    136144    return report
    137145}}}
     
    142150{{{
    143151def warehouse_report(jr, **attr):
    144     """" Warehouse report """
    145     <Code to produce the report>
    146     # Assemble the report as dict:
    147     report = dict(title="Page Title", ...)
     152
     153    """ Warehouse report generator """
     154
     155    # Code to produce the report items:
     156    title = T("Warehouse Report")
     157
     158    # Assemble the report items in a dict:
     159    report = dict(title=title, ...)
    148160    return report
    149161}}}
     
    157169{{{
    158170def warehouse_report(jr, **attr):
    159     """" Warehouse report """
     171
     172    """ Warehouse report generator """
     173
    160174    if jr.representation in ("html", "popup"):
    161         <Code to produce the interactive report>
    162         # Assemble the report as dict:
    163         report = dict(title="Page Title", ...)
     175        # Code to produce the report items:
     176        title = T("Warehouse Report")
     177
     178        # Assemble the report items in a dict:
     179        report = dict(title=title, ...)
     180
    164181    elif jr.representation == "xls":
    165         <Code to produce the XLS report>
     182        # Code to produce the XLS report goes here
     183        ...
     184
    166185    elif jr.representation in shn_xml_export_formats:
    167         <Code to produce the XML report>
     186        # Code to produce the XML report goes here
     187        ...
     188
    168189    else:
    169190        session.error = BADFORMAT
    170191        redirect(URL(r=jr.request))
     192
    171193    return report
    172194}}}
     
    180202    ...
    181203    elif jr.representation in shn_xml_export_formats:
    182         return export_xml(xrequest)
     204        report = export_xml(xrequest)
    183205    ...
    184206}}}
     
    190212    ...
    191213    elif jr.representation == "rss":
    192         <Code to produce the RSS report>
    193         return report
     214        # Code to produce the RSS report goes here
     215        report = ...
    194216    ...
    195217}}}