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


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

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Tutorial/RESTCustomisation

    v9 v10  
    1111{{{
    1212def myresource():
    13    """ RESTful CRUD controller """
     13
     14   """ RESTful CRUD controller """
     15
    1416   return shn_rest_controller(module, resource)
    1517}}}
     
    2123{{{
    2224def myresource():
    23    """ RESTful CRUD controller """
     25
     26   """ RESTful CRUD controller """
     27
    2428   output = shn_rest_controller(module, resource)
    2529   return output
     
    2933{{{
    3034def myresource():
    31    """ RESTful CRUD controller """
     35
     36   """ RESTful CRUD controller """
     37
    3238   output = shn_rest_controller(module, resource)
    3339   if isinstance(output, dict) and "form" in output:
    34        form = output.get("form")
    35        <your form manipulation here>
     40       form = output.get("form", None)
     41       if form:
     42           # Your code to manipulate the form goes here:
     43           ...
     44
    3645   return output
    3746}}}
     
    4049{{{
    4150def myresource():
    42    """ RESTful CRUD controller """
     51
     52   """ RESTful CRUD controller """
     53
    4354   output = shn_rest_controller(module, resource)
    4455   if isinstance(output, dict):
    45        if "form" in output:
    46            form = output.get("form")
    47            <your form manipulation here>
     56       form = output.get("form", None)
     57           if form:
     58               # Code to manipulate form goes here:
     59               ...
    4860       myitem = "I can send this item to the view"
    4961       output.update(myitem=myitem)
     62
    5063   return output
    5164}}}
     
    7689{{{
    7790def myresource():
    78    """ RESTful CRUD controller """
    79 
     91
     92   """ RESTful CRUD controller """
     93
     94   # Define pre-processor as local function:
    8095   def _prep(jr):
    8196       mylist = jr.request.vars.get("mylist")
     
    8398           s3rest.set_handler("list", my_list_controller)
    8499       return True # do not forget to return True!
     100
     101   # Hook pre-processor into REST controller:
    85102   response.s3.prep = _prep
    86103