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:        
    @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()

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.2.tar.gz (17.4 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.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: falcon_tryton-0.1.2.tar.gz
  • Upload date:
  • Size: 17.4 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.2.tar.gz
Algorithm Hash digest
SHA256 98b7435cc2d4c4f969b7cdaa5298dc4ccd9e71b7e84fda5f23d921dcdac65c6e
MD5 f7cf7f83fa16a23b56c3ccd9202115e3
BLAKE2b-256 67497cb737bf1fa967ed873522b7a33939c43fe383ef8f80957de06c4a4bc31f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: falcon_tryton-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b339c9a617bdd3d8b9fefaa828b17cbf4afa4a002f047c445095b2e1e13f2756
MD5 4673c822bff55b8d9bb9cd5e2024579d
BLAKE2b-256 d83700330f229b638f3d06143bfc764b353fee46845ea438f40c8c2951183e58

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