Changes between Version 9 and Version 10 of DeveloperGuidelines/Tutorial/RESTCustomisation
- Timestamp:
- 06/11/10 21:28:04 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Tutorial/RESTCustomisation
v9 v10 11 11 {{{ 12 12 def myresource(): 13 """ RESTful CRUD controller """ 13 14 """ RESTful CRUD controller """ 15 14 16 return shn_rest_controller(module, resource) 15 17 }}} … … 21 23 {{{ 22 24 def myresource(): 23 """ RESTful CRUD controller """ 25 26 """ RESTful CRUD controller """ 27 24 28 output = shn_rest_controller(module, resource) 25 29 return output … … 29 33 {{{ 30 34 def myresource(): 31 """ RESTful CRUD controller """ 35 36 """ RESTful CRUD controller """ 37 32 38 output = shn_rest_controller(module, resource) 33 39 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 36 45 return output 37 46 }}} … … 40 49 {{{ 41 50 def myresource(): 42 """ RESTful CRUD controller """ 51 52 """ RESTful CRUD controller """ 53 43 54 output = shn_rest_controller(module, resource) 44 55 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 ... 48 60 myitem = "I can send this item to the view" 49 61 output.update(myitem=myitem) 62 50 63 return output 51 64 }}} … … 76 89 {{{ 77 90 def myresource(): 78 """ RESTful CRUD controller """ 79 91 92 """ RESTful CRUD controller """ 93 94 # Define pre-processor as local function: 80 95 def _prep(jr): 81 96 mylist = jr.request.vars.get("mylist") … … 83 98 s3rest.set_handler("list", my_list_controller) 84 99 return True # do not forget to return True! 100 101 # Hook pre-processor into REST controller: 85 102 response.s3.prep = _prep 86 103