Changes between Version 57 and Version 58 of S3/S3REST/s3_rest_controller


Ignore:
Timestamp:
02/15/11 12:41:06 (11 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3REST/s3_rest_controller

    v57 v58  
    312312=== Filtering Lists ===
    313313
    314 You can filter lists by setting {{{response.s3.filter}}} to a filter query:
    315 
     314You can filter lists in the controller by setting {{{response.s3.filter}}} to a filter query:
    316315{{{
    317316    # This filters for females:
     
    321320}}}
    322321
     322Note that this only takes effect in the main controller (not in prep or postp).
     323
    323324Note that {{{response.s3.filter}}} affects both, the primary resource and components!
    324325
    325326In {{{prep}}}, you can also add filter queries using the {{{add_filter}}} method:
    326 
    327327{{{
    328328    def prep(r):
    329329        resource = r.resource
    330         query = (db.pr_address.type==1) # Home addresses only
     330        query = (db.pr_address.type == 1) # Home addresses only
    331331        resource.add_filter(query)
    332332        return True
     
    337337
    338338However, {{{add_filter}}} again affects both, primary and component records - so this example would:
    339 
    340339- only retrieve {{{person}}} records which have a type 1 {{{address}}} record
    341340- only retrieve the {{{address}}} records with type 1.
     
    344343
    345344To have the primary resource unfiltered, and filter only records in a particular component, you can use {{{add_component_filter}}}:
    346 
    347345{{{
    348346    def prep(r):
    349347        resource = r.resource
    350         query = (db.pr_address.type==1) # Home addresses only
     348        query = (db.pr_address.type == 1) # Home addresses only
    351349        resource.add_component_filter("address", query)
    352350        return True
     
    357355
    358356In this case, all {{{person}}} records would be selected - while only {{{address}}} records of type 1 would be retrieved.
    359 
    360 
    361357=== Pre-populating Create-Forms ===
    362358