What is Asset Tracker©
Asset Tracker© is a tool for creating and maintaining persistent data using Python. This tool can be used for web sites where
- The site administrator wants to change certain parts of the site without programming
- The site users/visitors should be able to post and contribute information to the web site
The data persists across sessions in a SQLite database. Asset Tracker© also provides lists and forms to display and manipulate the data. Applications can use these built-in, high-level views or create custom views using low-level database access functions.
Roster definition
- The data table contains the instances or objects of the roster, similar to a spread-sheet it consists of a collection of attributes (values, data items, table columns, form fields).
- The meta-data roster AT_meta contains information about all rosters (including itself), i.e., the definition/properties of its attributes.
- The data for each roster (data table and meta data) can be entered in two ways:
- Manually one instance at a time: select the table and click on 'Add an instance'.
- Read from a file: on the AT_config page click on 'Import Data' for the roster. See Roster mirrors.
- Note on roster naming - capitalize and use the single form, e.g. 'Event'.
Attribute properties
Each attribute has the following properties (captured in the AT_meta roster):
- tag : the name (format as program varibles)
- type : see Attribute types below
- init : initial value (except for files)
- required : a value has to be entered to save the instance
- show : or hide, the field is not visible in listing or form
- sort : the position in the listing and on the form
- key : needed to uniquely identify an instance
- alias : used as label in listing and form instead of tag
- width : on the form (in em or characters)
- height : on the form (in em or characters)
- tip : displayed on hover over the label
Attribute types
Asset Tracker provides the following attribute types:
- id : The internal database identifier (integer)
- number : Any numeric value, int, float
- text : A short textual field, typically one line long
- file : Saves an uploaded attachement (integer, Handling Files)
- long : A long textual field with rich-text propeties
- date : Date selector, stored as text
- menu : A drop-down, values are stored in AT_picks
- checks : Multi-select, values are stored in AT_picks
- radio : Single select, values are stored in AT_picks
- truth : Boolean, Yes-No values stored as text
System rosters
The following rosters are part of Asset Tracker© and must be present:
- AT_audit : when instances are created, changed, deleted
- AT_config : information about the application
- AT_file : contains files and meta data about all files. See below.
- AT_meta : contains information about all rosters (including itself)
- AT_pick : possible values for menu, radio and checkboxes attributes
- AT_roster : keeps track of all rosters
- AT_user : information about the registered users
Roster mirrors
System rosters and application level rosters can be stored to or read from text files (mirrors). These text files are in Excel csv format, containing one instance per line, with values separated by tabs. All mirrors are located in the Data folder. Mirrors are called rst.txt for a roster called rst.
- Roster ids are not saved in text files
- In text-type attributes new lines are replaced with <'br/'> when exporting, which are converted back to \\'n when importing
- Importing appends to existing instances, use 'Erase Data' first when needed
Handling Files
Files can NOT be stored directly in rosters, because at the very least the file name and the content are needed. So Asset Tracker stores all files (attributes of type 'file') along with their meta information (file name, etc.) in AT_file.
Rosters containing file-type attributes store ids of the corresponding AT_file instances.
Access permissions
The AT_table and AT_form modules are called with a CRUD parameter, which is a string with up to 4 unique characters. This section describes the use of this parameter.
- R - Read: if 'R' is specified then the user can access the table view. Usually this is combined with other permissions. If no other permissions are granted then the instnces in the table are not clickable and no buttons are displayed.
- C - Create:
- if 'C' is in CRUD then the table view will display 'Add an instance' button, which will bring up the form to enter the data for a new instance and press the 'Save Changes' button.
- If 'C' is specified but no 'R', then only the 'Add an instance' button is shown. The user does not see the containing table before or after creating an instance. This is useful to allow users to create and save an instance without being able to see other instances, e.g., submit application form.
- U - Update:
- if 'U' and 'R' are specified then in the table view instances are clickable, which will display the form for the corresponding instance with a 'Save Changes' button.
- 'U' without 'R' does not make sence.
- D - Delete:
- if 'D' and 'R' are specified, when a table instance is selected, the form view will display a 'Delete' button.
- 'D' without 'R' does not make sence.
Creating/Removing a roster
To create a new roster follow the steps below: (also refer to AT_util.init_app())
- Create the meta-data (copy and adjust an existing one in Data)
- Add the new instance to 'AT_rosters'. This will create the roster table, and import any data.
To remove a roster, delete it in 'AT_rosters' - this will delete all instances and entries in AT_meta and AT_file.
If configuration changes affect the name or the type of any attribute, then the roster must be emptied (delete its instances), while changes to other attributes don't require deleting existing instances.
Changing a roster
Steps for making changes to the structure of an existing roster (without files):
- Export any data
- Delete the roster from AT_rosters (this will remove roster's meta data from AT_meta)
- Make changes to roster's meta data
- Make changes to roster's mirror data (located in the Data folder)
- Add the roster to AT_rosters (this will add roster's meta data to AT_meta)
- Import data
To start over, delete the database file and then run 'AT_util.init_assetTracker().
Creating a new application
To create a new Asset Tracker© application follow the steps below:
- Copy the Asset Tracker folder to the new location (AT)
- For each new roster create a meta file in Data. Use sample_meta.txt as example
- Optionally, for each new roster create a data file in Data. Use sample.txt as example
- Method 1: Make changes using the config utility:
- Open home.html in the new location
- In AT_config change App name and site URLs
- Add/delete lines in AT_rosters, AT_picks and AT_users
- Export all rosters
- Method 2: Adjust mirrors in Data:
- In Data/AT_config.txt change App name and site URLs
- Add the new rosters in AT_rosters.txt
- Add/delete AT_picks.txt and AT_users.txt
- Call home.html, go to config:
- Run Initialize AssetTracker and Initialize App
- Delete the roster 'sample'
- Change home.html, home.py and AT_custom.py as needed
Asset Tracker© requirements
The items below are required in the home directory of the application using AT:
- A folder called 'Data' that contains the definitions and the data files for all rosters.
- A file called 'AT_custom.py', which contains instruction for creating, deleting, and updating items.
- A file called 'home.html' that is the default landing page of the application
- A file called 'index.html' that uses the AT authentication
- The directory call 'lib' that contains the Asset Tracker files
- The Asset Tracker database 'AssetTracker.db' that resides in lib
Please contact us with questions or suggestions.