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 | | |
| 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 |
| 312 | resource = current.s3db.resource("my_table") |
| 313 | |
| 314 | # Limit to certain record IDs |
| 315 | resource = current.s3db.resource("my_table", id=[1, 3, 7]) |
| 316 | |
| 317 | # Use a filter |
| 318 | from s3 import S3FieldSelector |
| 319 | resource = current.s3db.resource("my_table", filter=S3FieldSelector("id").belongs([1, 3, 7])) |
| 320 | |
| 321 | # Apply a URL filter |
| 322 | resource = current.s3db.resource("my_table", vars={"~.id__belongs": "1, 3, 7"}) |
| 323 | }}} |
| 324 | |