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 table 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 manually or read from text files.
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 globally, e.g., for hiding the content of binary files
- sort : the position in the listing and on the form
- key : key or keys uniquely identify an instance
- alias : if defined, it is used as label in table and form
- width : on the form (in em or characters)
- height : on the form (in em or characters)
- tip : show on hover in table and form
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 tables
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_files : contains files and meta data about all files. See below.
- AT_meta : contains information about all rosters (including itself)
- AT_picks : possible values for menu, radio and checkboxes attributes
- AT_rosters : keeps track of all rosters
- AT_users : 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.
- Table 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_files.
Rosters containing file-type attributes store ids of the corresponding AT_files instances.
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_files.
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
Known Limitations
- Must not use single quotes/apostrophes (') in text and long fields, form cannot display these.
Please contact us with questions or suggestions.