Changes between Version 17 and Version 18 of S3/S3Tracking


Ignore:
Timestamp:
06/13/14 12:19:35 (7 years ago)
Author:
MattS
Comment:

syntax highlighting

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Tracking

    v17 v18  
    1919
    2020As this is a pre-defined re-usable field, simply add it to your model:
    21 {{{
     21{{{#!python
    2222table = self.define_table(tablename,
    2323                          ...
     
    3030
    3131This can be done by defining {{{sit_trackable}}} as super-entity:
    32 {{{
     32{{{#!python
    3333table = self.define_table(tablename,
    3434                          ...
     
    4242
    4343There is no problem to have this together with other super-entities (the number of super-entities per table is not limited):
    44 {{{
     44{{{#!python
    4545table = self.define_table(tablename,
    4646                          ...
     
    6060
    6161You can create an S3Trackable by using the {{{s3tracker}}} function with the table and the record ID:
    62 {{{
     62{{{#!python
    6363trackable = s3tracker(db.my_table, 1)
    6464}}}
    6565
    6666Instead of the table, you can specify the tablename:
    67 {{{
     67{{{#!python
    6868trackable = s3tracker(tablename="my_table", record_id=1)
    6969}}}
    7070
    7171You can also specify a query:
    72 {{{
     72{{{#!python
    7373query = (db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34")
    7474trackable = s3tracker(query=query)
     
    7676
    7777or a record (must be a Row instance):
    78 {{{
     78{{{#!python
    7979record = db(db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34").select(limitby=(0, 1)).first()
    8080trackable = s3tracker(record=record)
     
    8585It is possible to specify a super-entity for an {{{S3Trackable}}}. In this case, the tracker will automatically find the respective records in the instance table(s) and use them instead:
    8686
    87 {{{
     87{{{#!python
    8888trackable = s3tracker(db.pr_pentity, 1) # <= the super-entity is automatically replaced by the respective instance record (e.g. in pr_person)
    8989}}}
     
    9292=== Base Location ===
    9393To retrieve the base location of an object, use {{{get_base_location()}}}:
    94 {{{
     94{{{#!python
    9595base_location = s3tracker(db.pr_person, 1).get_base_location()
    9696}}}
     
    9999
    100100To set the base location of an object, use set_base_location():
    101 {{{
     101{{{#!python
    102102s3tracker(db.pr_person, 1).set_base_location(25) # <= use the record ID of a gis_location
    103103}}}
    104104
    105105Other ways to specify the location:
    106 {{{
     106{{{#!python
    107107# Using a location record
    108108location = db(db.gis_location.id == 25).select(limitby=(0, 1)).first()
     
    120120=== Current location ===
    121121When setting/retrieving the current location of an object, you can additionally specify a time point:
    122 {{{
     122{{{#!python
    123123from datetime import datetime, timedelta
    124124one_hour_ago = datetime.utcnow() - timedelta(hours=1)
     
    129129
    130130To set a current location, you can use {{{set_location()}}}.
    131 {{{
     131{{{#!python
    132132s3tracker(db.pr_person, 1).set_location(25, timestmp=datetime.utcnow())
    133133}}}
     
    142142This can be achieved by using the {{{check_in()}}} and {{{check_out()}}} methods.
    143143
    144 {{{
     144{{{#!python
    145145>>> s3tracker(db.vt_vehicle, 1).set_location(40) # <= set a current location for the vehicle
    146146>>> s3tracker(db.pr_person, 1).check_in(db.vt_vehicle, 1) # <= check in the person to the vehicle
     
    164164
    165165If you specify a super-entity instance to check-in to, then the respective instance record will automatically be used:
    166 {{{
     166{{{#!python
    167167s3tracker(db.pr_person, 1).check_in(db.org_site, 4) # <= checks-in the person to the respective org_site instance, i.e. hospital or office...
    168168}}}