Plus Plus Service

Author: Aurelien Bompard <abompard@fedoraproject.org>

Plus Plus Service is a REST-based service to increment or decrement karma for Fedora users.

Installing

Plus Plus Service can be installed like any Python 3 package.

Configuration

To configure the application, you will need to create a settings file in the form of a Python module with global variables, as described in the Flask documentation.

The environment variable FLASK_SETTINGS must be set to this file's full path, for example:

export FLASK_SETTINGS=/path/to/project/settings.py

The following settings are used by Plus Plus Service:

DEBUG
Make sure you set it to False when deploying the application.
SQLALCHEMY_DATABASE_URI
The URI to the database, in SQLAlchemy's format.
FAS_URL
The URL to the FAS instance (defaults to Fedora's FAS instance).
FAS_USERNAME
The username to connect to the FAS API.
FAS_PASSWORD
The password for the FAS username.
PKGDB_URL
The URL to the PKGDB instance (defaults to Fedora's PKGDB instance).
PLUS_PLUS_TOKEN
The token to authenticate to this service. All POST requests must have an Authorization header containing "token THIS_TOKEN", otherwise the request will be rejected.
MEMCACHED
To improve the service's response time, you can use a Memcached server. Set this variable to the list of your Memcached addresses and ports, for example: MEMCACHED = ['127.0.0.1:11211']. This is optionnal.

Running the service

The database must be created first, and the application can be quickly run with the following commands:

export FLASK_SETTINGS=/path/to/your/custom/settings.py
plus-plus-service syncdb
export FLASK_APP=plus_plus_service
flask run

Plus Plus Service is based on Flask, you can deploy it by following Flask's documentation. Example configuration files for Apache are distributed in the deploy directory.

Development

First, create a virtual environment in the venv directory, then install the package and its dependencies in this virtual environment:

pyvenv venv
source ./venv/bin/activate
python setup.py develop

To create the database, use the following command:

plus-plus-service syncdb

If you want to run the service in debug mode, you can prefix the standard command with FLASK_DEBUG=1 or simply export the shell variable:

export FLASK_APP=plus_plus_service
export FLASK_DEBUG=1
flask run

Alembic commands can be run by pointing to the included ini file:

alembic -c plus_plus_service/alembic.ini current

The test suite can be run using the tox command.