Changes between Version 12 and Version 13 of S3/S3Tracking


Ignore:
Timestamp:
10/09/12 13:46:04 (12 years ago)
Author:
Fran Boon
Comment:

update to current

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Tracking

    v12 v13  
    4040                        ...)
    4141
    42 s3xrc.model.configure(table,
    43                       super_entity=db.sit_trackable, # <= configure sit_trackable as super-entity
    44                       ...)
     42s3db.configure(table,
     43               super_entity=db.sit_trackable, # <= configure sit_trackable as super-entity
     44               ...)
    4545}}}
    4646
     
    5454                        ...)
    5555
    56 s3xrc.model.configure(table,
    57                       super_entity=(db.org_site, db.sit_trackable), # <= multiple allowed!
    58                       ...)
     56s3db.configure(table,
     57               super_entity=(db.org_site, db.sit_trackable), # <= multiple allowed!
     58               ...)
    5959}}}
    6060
     
    6666
    6767You can create an S3Trackable by using the {{{s3tracker}}} function with the table and the record ID:
    68 
    6968{{{
    7069trackable = s3tracker(db.my_table, 1)
    7170}}}
    7271
    73 This works fine with record UUIDs too:
    74 
     72Instead of the table, you can specify the tablename:
    7573{{{
    76 trackable = s3tracker(db.my_table, uuid="9207324b-5dc6-439b-9410-8920cbaf8a34")
    77 }}}
    78 
    79 Instead of the table, you can also specify the tablename:
    80 
    81 {{{
    82 trackable = s3tracker("my_table", uuid="9207324b-5dc6-439b-9410-8920cbaf8a34")
     74trackable = s3tracker(tablename="my_table", record_id=1)
    8375}}}
    8476
    8577You can also specify a query:
    86 
    8778{{{
    88 trackable = s3tracker(db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34")
     79query = (db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34")
     80trackable = s3tracker(query=query)
    8981}}}
    9082
    9183or a record (must be a Row instance):
    92 
    9384{{{
    9485record = db(db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34").select(limitby=(0, 1)).first()
    95 trackable = s3tracker(record)
    96 }}}
    97 
    98 or a set of records (must be a Rows instance):
    99 
    100 {{{
    101 records = db(db.my_table.id.belongs(1, 2, 3, 4)).select()
    102 trackable = s3tracker(records)
     86trackable = s3tracker(record=record)
    10387}}}
    10488
     
    11599
    116100To retrieve the base location of an object, use {{{get_base_location()}}}:
    117 
    118101{{{
    119102base_location = s3tracker(db.pr_person, 1).get_base_location()
     
    123106
    124107To set the base location of an object, use set_base_location():
    125 
    126108{{{
    127109s3tracker(db.pr_person, 1).set_base_location(25) # <= use the record ID of a gis_location
     
    129111
    130112Other ways to specify the location:
    131 
    132113{{{
    133114# Using a location record
     
    147128
    148129When setting/retrieving the current location of an object, you can additionally specify a time point:
    149 
    150130{{{
    151131from datetime import datetime, timedelta
     
    157137
    158138To set a current location, you can use {{{set_location()}}}.
    159 
    160139{{{
    161140s3tracker(db.pr_person, 1).set_location(25, timestmp=datetime.utcnow())