Changes between Version 18 and Version 19 of S3/S3Model


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

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Model

    v18 v19  
    275275}}}
    276276
    277 === Constructing Resources ===
    278 
    279 {{{current.s3db}}} also provides a method to define a resource (see [wiki:S3/S3Resource]):
    280 
    281 {{{#!python
    282 # Define a resource
    283 resource = current.s3db.resource("my_table")
    284 
    285 # Limit to certain record IDs
    286 resource = current.s3db.resource("my_table", id=[1, 3, 7])
    287 
    288 # Use a filter
    289 from s3 import S3FieldSelector
    290 resource = current.s3db.resource("my_table", filter=S3FieldSelector("id").belongs([1, 3, 7]))
    291 
    292 # Apply a URL filter
    293 resource = current.s3db.resource("my_table", vars={"~.id__belongs": "1, 3, 7"})
    294 }}}
    295 
    296 == Utilities ==
    297 
    298277=== Table Configuration Settings ===
    299278
     
    309288  '''Note:''' In {{{get_config()}}}, the <default> parameter is optional (default: {{{None}}}), it will be returned if <key> is not configured for this table.
    310289
    311   '''Note:''' These functions are available both as instance methods in S3Models (self.* or current.s3db.*) and as class methods (S3Model.*).
     290  '''Note:''' These functions are available both in S3Model instances (self.* or current.s3db.*) and as class methods (S3Model.*).
    312291
    313292  '''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()}}}) after the model has been loaded (e.g. with {{{s3db.<tablename>}}})!
     
    325304}}}
    326305
     306=== Constructing Resources ===
     307
     308{{{current.s3db}}} also provides a method to define a resource (see [wiki:S3/S3Resource]):
     309
     310{{{#!python
     311# Define a resource
     312resource = current.s3db.resource("my_table")
     313
     314# Limit to certain record IDs
     315resource = current.s3db.resource("my_table", id=[1, 3, 7])
     316
     317# Use a filter
     318from s3 import S3FieldSelector
     319resource = current.s3db.resource("my_table", filter=S3FieldSelector("id").belongs([1, 3, 7]))
     320
     321# Apply a URL filter
     322resource = current.s3db.resource("my_table", vars={"~.id__belongs": "1, 3, 7"})
     323}}}
     324
    327325----
    328326