Trie
Using the Trie wrapper
Before you can use the Trie file to match user agent strings to devices you will need to install the 51Degrees python Trie wrapper. In your terminal, navigate to the correct directory which will probably be the same directory you have used in Step 1 of the Getting Started guide. Then, run the following command.
$ sudo
pip install 51degrees-mobile-detector-v3-trie-wrapper
After the install is successfully complete you will need to change the following lines in your 51degrees-mobile-detector.settings.py file:
DETECTION_METHOD should be set to 'v3-trie-wrapper'
# DETECTION_METHOD = 'v3-trie-wrapper'
A path to the Trie file should also be specified. In this example my Trie file is located in the same directory as the settings file.
############################################################################### ## TRIE DETECTOR (C WRAPPER) SETTINGS. ############################################################################### # Location of the database file. If not specified, the trie-based detection # method will not be available. Download the latest 51Degrees.mobi-Lite-*.trie.zip # file from http://sourceforge.net/projects/fiftyone-c/files/. # TRIE_WRAPPER_DATABASE must be renamed to V3_TRIE_WRAPPER_DATABASE. V3_TRIE_WRAPPER_DATABASE = '51Degrees.trie'
Please note: the configuration file produced by default creates a setting called TRIE_WRAPPER_DATABASE. To use with version 3 this setting must be renamed to V3_TRIE_WRAPPER_DATABASE as in the above snippet.
Your Trie matching is now set up. Use it the same way you would use the Pattern matching - by calling the mobile_detector.match(). For some examples please see the Getting Started section.