Changes between Version 36 and Version 37 of S3/S3Model/ComponentResources

01/11/13 10:27:41 (12 years ago)
Dominic König



  • S3/S3Model/ComponentResources

    v36 v37  
    7676s3db.add_component("org_office", org_organisation={
    77                                         "name": "headquarters",         # the component alias
     77                                        "name": "headquarter",          # the component alias
    7878                                        "joinby": "organisation_id"     # the foreign key
    7979                                 })
    8585s3db.add_component("org_office", org_organisation={
    86                                         "name": "headquarters",         # the component alias
     86                                        "name": "headquarter",          # the component alias
    8787                                        "joinby": "organisation_id"     # the foreign key
    8888                                        "filterby": "office_type_id",   # the name of the field in the component table to filter by
    9595It is possible to link the same component table to the same master table more than once using different joins and/or filters.
     97Sometimes it may be necessary to move fields out of the master table into a component in order to have better control over access permissions to these fields, or to hold the same fields for multiple master tables in a single table. In these cases the a record in the master table can only have exactly one corresponding record in the component.
     99This requirement is often called "singe-record component" or "subtable", and can be defined in the join dict:
     102s3db.add_component("org_office", org_organisation={
     103                                        "name": "headquarter",          # the component alias
     104                                        "joinby": "organisation_id"     # the foreign key
     105                                        "filterby": "office_type_id",   # the name of the field in the component table to filter by
     106                                        "filterfor": 4,                 # the value(s) to filter for
     107                                        "multiple": False               # there can be only one component record per master record
     108                                 })
     111Most Eden modules respect the multiple-setting and enforce a single component record per master record.
     113IMPORTANT: Note that it is possible, but '''not recommendable''', to change the multiple-setting dynamically in the controller environment: setting multiple=False does not allow to choose a particular component record, but simply selects the first (by ID) that matches the query. Thus, where the query can change (e.g. due to different authorization levels), then it is difficult to predict which record that would be, and different users may see different records despite multiple=False (which can be deliberate at times, though).
    97114== Link-Table Components ==