Changes between Version 15 and Version 16 of S3/S3Model


Ignore:
Timestamp:
01/24/14 08:30:02 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Model

    v15 v16  
    275275}}}
    276276
    277 === Utility Functions ===
    278 
    279 {{{current.s3db}}} also provides the {{{S3Model}}} utility functions, e.g.:
    280 
    281 {{{#!python
    282 # Change a table configuration
    283 current.s3db.configure("my_table", list_fields=["id", "name", "other_field"])
    284 }}}
    285 
    286    '''Note:''': {{{s3db.get_config()}}} does not load the respective model, so unless you have loaded the model before, you can not access its configuration settings!
    287 
    288277=== Constructing Resources ===
    289278
     
    305294}}}
    306295
     296== Utilities ==
     297
     298=== Table Configuration Settings ===
     299
     300{{{S3Model}}} provides a key-value store for each table which is used to store per-table configuration settings.
     301
     302The following functions can be used to manage table configuration settings:
     303
     304||= '''Function''' =||= '''Use-Case''' =||
     305||{{{configure(<tablename>, <key>=<value>, <key>=<value>, ...)}}}||to add or change configuration settings for a table||
     306||{{{get_config(<tablename>, <key>, <default>)}}}||to retrieve a configuration setting||
     307||{{{clear_config(<tablename>, <key>)}}}||to remove a configuration setting for a table||
     308
     309  '''Note:''' In {{{get_config()}}}, the <default> parameter is optional (default: {{{None}}}), it will be returned if <key> is not configured for this table.
     310
     311  '''Note:''' These functions are available both as instance methods in S3Models (self.* or current.s3db.*) and as class methods (S3Model.*).
     312
     313  '''Important:''': {{{get_config()}}} does ''not'' load the respective model class. Settings configured inside the model class are therefore only available outside of it (e.g. with {{{s3db.get_config()}}}) if the model has been loaded before (e.g. with {{{s3db.<tablename>}}})!
     314
     315Example:
     316{{{#!python
     317# Configure list_fields for the org_organisation table
     318s3db.configure("org_organisation",
     319               list_fields=["id",
     320                            "name",
     321                            "acronym",
     322                            "organisation_type_id",
     323                            "country",
     324                            "website"])
     325}}}
     326
    307327----
    308328