Skip to main content

Adds Tryton support to Falcon application

Project description

Falcon-Tryton

Adds Tryton support to Falcon application.

#! -*- coding: utf8 -*-

from functools import wraps
from falcon_tryton import Tryton
import falcon
import os

CONTEXT = None
CONFIG = {}
CONFIG['TRYTON_DATABASE'] = os.environ.get('DB_NAME', 'mydb') 
CONFIG['TRYTON_USER'] = 0

app = falcon.App()

tryton = Tryton(app, CONFIG)

User = tryton.pool.get('res.user')
        
# @tryton.default_context
# def default_context():
#     global CONTEXT
#     if not CONTEXT:
#         CONTEXT = User.get_preferences(context_only=True)
#     return CONTEXT    

class ApiUser:
    def __init__(self, tryton = None):
        self.tryton = tryton
        
    @tryton.transaction()
    def on_get(self, req, resp):
        resp.status = falcon.HTTP_200
        users = User.browse([1])       
        resp.media = {'name':users[0].name}

apiuser = ApiUser(tryton)

app.add_route("/user", apiuser)



# wsgi gunicorn o uwsgi:

""" example file wsgi_falcon.py:

            from app_falcon import app
"""
# important: no use app.run()

There are three configuration options available:

  • TRYTON_DATABASE: the Tryton's database to connect.
  • TRYTON_USER: the Tryton user id to use, by default 0 (aka root).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

falcon_tryton-0.1.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

falcon_tryton-0.1.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file falcon_tryton-0.1.1.tar.gz.

File metadata

  • Download URL: falcon_tryton-0.1.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for falcon_tryton-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bea798188e91fc5ef9c70b96cbfef09229123ccec0a7a13d5be98de8316e02bf
MD5 be469afbceec29dea6e1d75f3f57dcc5
BLAKE2b-256 da2541875baaf8b392f7269077f3edfac7390888b230ca78be8a5183c8f76760

See more details on using hashes here.

File details

Details for the file falcon_tryton-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: falcon_tryton-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for falcon_tryton-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9004134f838ff4b830787e196a08d51e8f1779fe92634dd199f1f6d6538bdf41
MD5 7c3d7306d415c03a4595619e4c5e9afa
BLAKE2b-256 86a220921de2ee5fa8d878952233ba8145cf7a31d17c9fc25dcdfd4569c46444

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page