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.3.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.3-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: falcon_tryton-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 7a68a705536d5cdc15a86be6ab2d021ba6bd8f9cfa5b0810d4639ace78dd8c7a
MD5 8b45058838e4fad9de2445051a3abb4a
BLAKE2b-256 9fd98fce7b15c5f9ea5fd98bb23a704f3f334326ab12273f9a416bdff363a5b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: falcon_tryton-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a936cb0ae03b76ad054f79179c042db01ca398aceb8c520a144e29ac987eecd1
MD5 9dacad023d41fc8271892cde62800c19
BLAKE2b-256 174f72319f3959b1df99a51430f5299b9c847411f27e9a44db0035799f9fcf6c

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