Some notes on playing around with Tryton
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
pukkamustard 2f5a6a3c26 add requirements.txt 10 months ago
.gitignore just use pip... 10 months ago
Readme.org first steps to a Flask app 10 months ago
app.py first steps to a Flask app 10 months ago
config some more notes 12 months ago
guix.scm first steps to a Flask app 10 months ago
requirements.txt add requirements.txt 10 months ago

Readme.org

Notes on playing with tryton

Environment

I'm using Guix to setup a suitable environment:

  guix shell -D -f guix.scm

Initial setup

Create a configuration

  [database]
  uri=sqlite://
  path=/home/aa/projects/trondheim-kooperativ/hello-tryton/db

See https://docs.tryton.org/projects/server/en/latest/topics/configuration.html#topics-configuration

  • path needs to be an absolute path to a directory

Initialize Database

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

Administration

Starting Server

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.

Adding modules

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.

Client

Run the tryton GUI client. Connect with localhost, database "test" and user "admin".

sao

sao is a JavaScript/Web client for Tryton. Functionality seems to be same as the GTK+ client.

I cloned and built it in a seperate checkout.

To make it load on / of the Tryton server add this to your config:

  [web]
  root=/home/aa/projects/trondheim-kooperativ/sao/

Modules

User roles

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!

flask-tryton

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.

Resources

Tryton Documentation

The official documentation site. There's not so much there, unfortunately…

Tryton Technical Training

Slides from 2015. Still a valuable intro to Tryton.