The Metadata Standards Catalog is written in Python 3, so as a first step
this will need to be installed on your machine. You will also need quite a few
non-standard packages, but all of them are easily available via the pip
utility:
- For the actual rendering of the pages you will need Flask, Flask-WTF (and hence WTForms), and Flask-Login.
- For Open ID v2.x login support, you will need Flask-OpenID.
- For Open ID Connect (OAuth) support, you will need RAuth (and hence Requests), and Google's oauth2client.
- For API authentication, you will need Flask-HTTPAuth and PassLib
- For database capability, you will need TinyDB v3.6.0+, tinyrecord, and RDFLib.
- For version control of the databases, you will need Dulwich.
The Catalog is compatible with Flask 0.10 (this is what python3-flask gives
you in Ubuntu 16.04 LTS), but can be used with later versions.
If you are testing the Catalog on your own machine, you can run it directly from the working directory (see below).
If you are setting up an instance of the Catalog on a live Web server, please refer to the deployment options documented by the Flask developers.
The key files and folders you need are these:
- the application itself,
serve.py; - the base configuration folder
config; - the
staticandtemplatesfolders; - the vocabulary RDF file,
simple-unesco-thesaurus.ttl.
If you do not set an instance folder for yourself, one will be created for you.
The Catalog will look in the following places for configuration options, in the following order:
- The
configfolder, in the filefor.py. - The
instancefolder (in the same directory as theserve.pyscript), in the filekeys.cfg. - A file specified by the environment variable MSC_SETTINGS.
Settings are applied in the order they are discovered, so later ones override earlier ones.
To set an environment variable on UNIX-like systems, you will need to include the following line in your shell profile (or issue the command from the command line):
export MSC_SETTINGS=/path/to/settings.cfgOn Windows, you can run the following from the command prompt.
set MSC_SETTINGS=\path\to\settings.cfgThe Catalog uses three NoSQL databases, which are saved to disk in the form of JSON files. You can either supply pre-populated versions of these files, or let the Catalog create them for you:
- The Main database holds the records for schemes, tools, mappings, etc.
- The User database holds the user profiles.
- The OAuth database holds OAuth URLs discovered dynamically.
The Catalog also uses an Open ID folder for holding temporary files while authenticating users using the Open ID v2 protocol.
You can configure the names and locations of these files and the folder by putting the respective paths in one of your configuration files:
MAIN_DATABASE_PATH = os.path.join('path', 'to', 'file.json') # default: instance/data/db.json
USER_DATABASE_PATH = os.path.join('path', 'to', 'file.json') # default: instance/data/users.json
OAUTH_DATABASE_PATH = os.path.join('path', 'to', 'file.json') # default: instance/oauth-urls.json
OPENID_PATH = os.path.join('path', 'to', 'folder') # default: instance/open-idOne way of pre-populating the Main database is to generate the JSON file from
the YAML files in the db folder using the dbctl.py script. See the
Administrator's Guide for more information on this.
To secure the installation, you should choose your own secret key and add it
to one of your configuration files, overriding the one in for.py:
SECRET_KEY = 'secret string'To be able to use Open ID Connect (OAuth), you will need to include IDs and secret codes from the Open ID providers in your configuration like this:
OAUTH_CREDENTIALS = {
'google': {
'id': 'id string',
'secret': 'secret string'},
'linkedin': {
'id': 'id string',
'secret': 'secret string'},
'twitter': {
'id': 'id string',
'secret': 'secret string'}}I have registered a set of these for use in the official instance at https://rdamsc.dcc.ac.uk, should there be demand.
Open up a fresh terminal/command prompt (as it will block the command line for
as long as the script is running) and run the script serve.py. Depending on
your operating system you might be able to run the script directly:
./serve.pyOtherwise you might need to invoke python or python3:
python3 serve.pyYou should then be able to access the Catalog in your Web browser using the URL the script shows you, e.g. http://127.0.0.1:5000/.
Again, please refer to the deployment options documented by the Flask developers for how to run the Catalog in production.