Changes between Version 8 and Version 9 of DeveloperGuidelines/Tutorial/RESTCustomisation
- Timestamp:
- 06/11/10 21:24:40 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Tutorial/RESTCustomisation
v8 v9 111 111 - '''!http://site.myserver.org/eden/wm/warehouse/report.xml''' 112 112 113 How to tackle this? 114 115 Yes - you can use shn_rest_controller for this! 116 117 This could be your "warehouse" controller: 113 How to tackle this? Yes - you can use shn_rest_controller for this! 114 115 This could be your "warehouse" CRUD controller: 118 116 119 117 {{{ 120 118 def warehouse(): 119 121 120 """ RESTful CRUD controller """ 121 122 122 return shn_rest_controller(module, resource, ...) 123 123 }}} … … 127 127 {{{ 128 128 def warehouse(): 129 """ RESTful CRUD controller """ 129 130 """ RESTful CRUD+Reports controller """ 131 132 # Plug warehouse_report into warehouse resource: 130 133 s3xrc.model.set_method(module, resource, method="report", action=warehouse_report) 134 131 135 return shn_rest_controller(module, resource, ...) 132 136 133 137 def 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 136 144 return report 137 145 }}} … … 142 150 {{{ 143 151 def 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, ...) 148 160 return report 149 161 }}} … … 157 169 {{{ 158 170 def warehouse_report(jr, **attr): 159 """" Warehouse report """ 171 172 """ Warehouse report generator """ 173 160 174 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 164 181 elif jr.representation == "xls": 165 <Code to produce the XLS report> 182 # Code to produce the XLS report goes here 183 ... 184 166 185 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 168 189 else: 169 190 session.error = BADFORMAT 170 191 redirect(URL(r=jr.request)) 192 171 193 return report 172 194 }}} … … 180 202 ... 181 203 elif jr.representation in shn_xml_export_formats: 182 re turnexport_xml(xrequest)204 report = export_xml(xrequest) 183 205 ... 184 206 }}} … … 190 212 ... 191 213 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 = ... 194 216 ... 195 217 }}}