7 | | [wiki:S3XRC/RESTfulAPI/URLFormat URL Format] |
8 | | |
9 | | == Old Ideas == |
10 | | Information on alternatives is listed below: |
11 | | {{{gluon/tools.py}}} supports easy exposing of functions to XMLRPC or JSONRPC: |
12 | | * http://web2py.com/examples/default/tools#services |
13 | | * http://groups.google.com/group/web2py/browse_thread/thread/53086d5f89ac3ae2 |
14 | | (originally in T3: http://groups.google.com/group/web2py/browse_thread/thread/9ec8b06b158adb75): |
15 | | |
16 | | Model: |
17 | | {{{ |
18 | | from gluon.tools import Service |
19 | | service = Service(globals()) |
20 | | }}} |
21 | | Controller: |
22 | | {{{ |
23 | | @service.jsonrpc |
24 | | @service.xmlrpc |
25 | | @service.amfrpc |
26 | | def organisation(): |
27 | | "RESTlike CRUD controller" |
28 | | return shn_rest_controller(module, 'organisation') |
29 | | }}} |
30 | | |
31 | | Can test authentication/REST using wget/curl: |
32 | | * http://groups.google.com/group/web2py/msg/dde8335c4ec26b99 |
33 | | * Rest-UI client: http://code.google.com/p/rest-client/ |
34 | | Token-based authentication: |
35 | | * http://groups.google.co.uk/group/web2py/browse_thread/thread/98258d69b6a6f927 |
36 | | |
37 | | Note that most web-services clients don't support cookies & hence are stateless (no sessions support): |
38 | | * http://groups.google.com/group/web2py/browse_thread/thread/6538ae13cb8f28d3 |
39 | | * use {{{session.forget()}}} inside controllers expecting such clients |
40 | | * XML-RPC client which does support Cookies: http://code.activestate.com/recipes/501148/ |
41 | | |
42 | | ---- |
43 | | We can access data from the database exported as JSON (for easy use within Javascript clients) by simply calling the [https://trac.sahana3.org/wiki/BluePrintREST RESTlike controller] with the var {{{?format=json}}}: |
44 | | {{{ |
45 | | /sahana/module/resource?format=json # Lists all records of this resource |
46 | | /sahana/module/resource/id?format=json # Display record with record.id==id |
47 | | /sahana/module/resource/create?format=json # ToDo |
48 | | /sahana/module/resource/update/id?format=json # ToDo |
49 | | }}} |
50 | | |
51 | | ---- |
52 | | Another approach (using JSONRPC e.g. with [http://pyjs.org Pyjamas]): |
53 | | * http://mdp.cti.depaul.edu/AlterEgo/default/show/203 |
54 | | * http://groups.google.com/group/web2py/browse_thread/thread/9bb107c2fbd1a34b |
55 | | ---- |
56 | | Twitter feeds as JSON: |
57 | | * http://groups.google.com/group/web2py/browse_thread/thread/bb9b5ddca40d0c87 |
58 | | |
59 | | ---- |
60 | | DeveloperGuidelines |
| 7 | * [wiki: S3#RESTfulAPI] |