Changes between Version 15 and Version 16 of JoinedResourceController
- Timestamp:
- 11/19/09 10:18:27 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
JoinedResourceController
v15 v16 3 3 = Joined Resource Controller = 4 4 5 * Code: [https://code.launchpad.net/~flavour/sahana/sahanapy-trunk Main Trunk] Revision 280+5 * Code: [https://code.launchpad.net/~flavour/sahana/sahanapy-trunk Main Trunk] Revision 358+ 6 6 7 This extends the single-table [wiki:BluePrintRESTImplementation REST Implementation] for requests for joined resources. 7 == Architecture == 8 8 9 A joined resource request is a request for a resource ("joined resource") in dependency of a join to another table ("primary resource"). 9 ''General:'' 10 10 11 In this implementation, these joins can be 1:1 or 1:N, and they can be natural joins (same key field in both tables) or primary/foreign key matches, where the primary key is always the 'id' field in the primary table. 11 * '''General:''' REST Interface <-> Front-End <-> Resource Controller <-> web2py backend 12 * '''JSON:''' REST Interface <-> JSON converter <-> XML Resource Controller <-> web2py DAL backend 13 * '''XML:''' REST Interface <-> XSLT Transformer <-> XML Resource Controller <-> web2py DAL backend 14 * '''HTML:''' REST Interface <-> web2py HTML frontend <-> CRUD Controller <-> web2py DAL backend 12 15 13 The controller function for thisis:16 The main controller function of the REST Interface is: 14 17 15 18 * '''shn_rest_controller''' (defined in models/01_RESTlike_controller.py) 19 20 The XML Interface supports in-line XSLT transformation in order to support various XML formats. 21 22 == Joined Resources == 23 24 This extends the single-table [wiki:BluePrintRESTImplementation REST Implementation]. 25 26 A joined resource request is a request to a table ("joined resource" or "component") in dependency of a join to another table ("primary resource" or simply "resource"), e.g.: 27 28 * the list of addresses (=component) of a person (=resource). 29 30 There are different ways how "Joined Resources" can be seen: 31 32 a) as subtables of database tables 33 b) as structured properties of object classes 34 c) as component classes within data compounds 35 36 In this implementation, component resources can be joined 1:1 or N:1 to their primary resources, either by natural joins (same key field in both tables) or primary/foreign key matches, where the primary key is always the 'id' field in the primary table. 16 37 17 38 == Model == … … 32 53 33 54 # Joined Resource 34 jrlayer.add_jresource(module, resource,55 s3xrc.model.add_component(module, resource, 35 56 multiple=True, 36 57 joinby='pr_pe_id', … … 55 76 56 77 No definitions are required at the primary resource, just define the table as usual. 78 57 79 == Controller == 58 80