Notes on playing with tryton
- Initial setup
- A Flask Application
I'm using Guix to setup a suitable environment:
guix shell -D -f guix.scm
Create a configuration
[database] uri=sqlite:// path=/home/aa/projects/trondheim-kooperativ/hello-tryton/db
- path needs to be an absolute path to a directory
Tryton seems to be able to use multiple databases from one instance. When connecting to the server on needs to specify the database.
Also Tryton does not seem to be able to create a sqlite database if the file does not exist. So we need to manually create an empty sqlite database:
sqlite3 db/test.sqlite 'create table blups(id smallint);'
Then we can run the
tryton-admin command (this will interactively ask for password):
trytond-admin -c config -d test --all
trytond --dev -v -d test -c config
This will start a HTTP server listening at localhost:8000. However there does not seem to be anything at the root of the server.
Seems like Tryton uses some Python trick for finding modules (beets does something similar). Install them with Guix and then run:
trytond-admin -c config -d test --update-modules-list
This will make the modules available. They now can be activated by an admin by logging in.
tryton GUI client. Connect with localhost, database "test" and user "admin".
I cloned and built it in a seperate checkout.
To make it load on
/ of the Tryton server add this to your config:
Authorizaiton is based on group membership (https://docs.tryton.org/projects/server/en/latest/topics/access_rights.html).
Users can be members of groups.
With the user roles module a role can be defined as a set of groups. Users can then be given a role. A role can also be given for a fixed period of time. This can be used for a membership that needs to be renewed.
TODO Relating to membership payment
It seems possible to relate the assignment of a role to a user (a record) to other records. This would be nice in order to link a role assignement record to a membership payment record.
A Flask Application
There is a small Flask application in
app.py. This app connects to Tryton using the Proteus library and exposes an HTML interface.
To start the application:
FLASK_APP=app.py FLASK_ENV=development flask run
This will reload on changes in the source. Pretty neat!
I've tried using this. It didn't work reliably (error when running flask command). It seems to add a lot of magic but documentation is bad (as everything in Tryton). I don't think it's worth using.