Changes between Version 12 and Version 13 of S3/S3Tracking
- Timestamp:
- 10/09/12 13:46:04 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3/S3Tracking
v12 v13 40 40 ...) 41 41 42 s3 xrc.model.configure(table,43 44 42 s3db.configure(table, 43 super_entity=db.sit_trackable, # <= configure sit_trackable as super-entity 44 ...) 45 45 }}} 46 46 … … 54 54 ...) 55 55 56 s3 xrc.model.configure(table,57 58 56 s3db.configure(table, 57 super_entity=(db.org_site, db.sit_trackable), # <= multiple allowed! 58 ...) 59 59 }}} 60 60 … … 66 66 67 67 You can create an S3Trackable by using the {{{s3tracker}}} function with the table and the record ID: 68 69 68 {{{ 70 69 trackable = s3tracker(db.my_table, 1) 71 70 }}} 72 71 73 This works fine with record UUIDs too: 74 72 Instead of the table, you can specify the tablename: 75 73 {{{ 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") 74 trackable = s3tracker(tablename="my_table", record_id=1) 83 75 }}} 84 76 85 77 You can also specify a query: 86 87 78 {{{ 88 trackable = s3tracker(db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34") 79 query = (db.my_table.uuid == "9207324b-5dc6-439b-9410-8920cbaf8a34") 80 trackable = s3tracker(query=query) 89 81 }}} 90 82 91 83 or a record (must be a Row instance): 92 93 84 {{{ 94 85 record = 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) 86 trackable = s3tracker(record=record) 103 87 }}} 104 88 … … 115 99 116 100 To retrieve the base location of an object, use {{{get_base_location()}}}: 117 118 101 {{{ 119 102 base_location = s3tracker(db.pr_person, 1).get_base_location() … … 123 106 124 107 To set the base location of an object, use set_base_location(): 125 126 108 {{{ 127 109 s3tracker(db.pr_person, 1).set_base_location(25) # <= use the record ID of a gis_location … … 129 111 130 112 Other ways to specify the location: 131 132 113 {{{ 133 114 # Using a location record … … 147 128 148 129 When setting/retrieving the current location of an object, you can additionally specify a time point: 149 150 130 {{{ 151 131 from datetime import datetime, timedelta … … 157 137 158 138 To set a current location, you can use {{{set_location()}}}. 159 160 139 {{{ 161 140 s3tracker(db.pr_person, 1).set_location(25, timestmp=datetime.utcnow())