Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] FastAPI Integration #291

Merged
merged 30 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d071de2
[ADD] Allows use of fastapi into Odoo!
lmignon Sep 23, 2022
f2f56ac
[IMP] fastapi: Uses contextvars to hold and provide odoo env on fasta…
lmignon Sep 27, 2022
e7b7b3b
[IMP] fastapi: renames fastapi.app into fastapi.endpoint
lmignon Sep 28, 2022
aa3bcd7
[IMP] fastapi: code cleanup
lmignon Oct 8, 2022
779a0a9
[IMP] fastapi: Improves modularity and demo app
lmignon Oct 8, 2022
a02ecd9
[IMP] fastapi: Add dependency method
lmignon Oct 9, 2022
9445431
[IMP] fastapi: Implement error handling
lmignon Dec 7, 2022
3835a31
[IMP] fastapi: Allows to define the user executing the api calls
lmignon Dec 10, 2022
615467f
[IMP] fastapi: Add authenticated_partner_id into ir.rule eval context
lmignon Dec 10, 2022
d11cda1
[IMP] fastapi: Add helper code to ease development of search route ha…
lmignon Dec 10, 2022
b90df58
[IMP] fastapi: documentation
lmignon Dec 10, 2022
73173b5
[FIX] add test dependency for fastapi
lmignon Dec 10, 2022
ab34529
Fix a few typos
sbidoul Dec 10, 2022
790d23f
Fix typo
lmignon Dec 12, 2022
dca1b58
little fixes
lmignon Jan 27, 2023
e510d12
[FIX] fastapi: Uses new implementation of endpoint_route_handler
lmignon Feb 24, 2023
190a0f5
[FIX] fastapi: change annotation to support python 3.7+
lmignon Feb 24, 2023
a9b316e
[ADD] extendable_fastapi: New addon to allow the use of extendable wi…
lmignon Feb 24, 2023
2e7e656
[FIX] fastapi: typo
lmignon Feb 26, 2023
7e12401
[IMP] extendable_fastapi: Relicence to lgpl
lmignon Feb 26, 2023
1a750d4
[IMP]fastapi: Uses the accept-languages header to determine the expex…
lmignon Feb 27, 2023
c9229e9
[IMP] fastapi: Register only one handler by application
lmignon Feb 27, 2023
0ce0b6c
[IMP] extendable_fastapi: Ensure extended pydantic models are working
lmignon Feb 27, 2023
28dbf1b
[IMP] fastapi: Improves UX for the endpoint registry synchronisation
lmignon Feb 27, 2023
61bffe6
[IMP] fastapi: Improves documentation
lmignon Feb 27, 2023
c121741
[IMP] fastapi: Improves documentation on security aspects
lmignon Mar 10, 2023
f1cfc32
[IMP] fastapi: Declared as Beta
lmignon Apr 24, 2023
6ea99a9
[IMP] fastapi: Typos
lmignon Apr 24, 2023
ee0c889
Fix schema generation
lmignon Jun 7, 2023
118742a
[FIX] fastapi: odoo-addon-endpoint-route-handler is merged
lmignon Jun 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions extendable_fastapi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
==================
Extendable Fastapi
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
:target: https://github.com/OCA/rest-framework/tree/16.0/extendable_fastapi
:alt: OCA/rest-framework
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rest-framework-16-0/rest-framework-16-0-extendable_fastapi
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/271/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon is a technical addon used to allows the use of
`extendable <https://pypi.org/project/extendable/>`_
classes in the implementation of your fastapi endpoint handlers. It also
allows you to use `extendable_pydantic <https://pypi.org/project/extendable_pydantic/>`_
models when defining your endpoint handlers request and response models.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20extendable_fastapi%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Laurent Mignon <laurent.mignon@acsone.eu> (https://acsone.eu)

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-lmignon| image:: https://github.com/lmignon.png?size=40px
:target: https://github.com/lmignon
:alt: lmignon

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-lmignon|

This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/16.0/extendable_fastapi>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions extendable_fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions extendable_fastapi/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Extendable Fastapi",
"summary": """
Allows the use of extendable into fastapi apps""",
"version": "16.0.1.0.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["lmignon"],
"website": "https://github.com/OCA/rest-framework",
"depends": ["fastapi", "extendable"],
"data": [],
"demo": [],
"external_dependencies": {
"python": [
"extendable-pydantic>=0.0.4",
],
},
"installable": True,
}
1 change: 1 addition & 0 deletions extendable_fastapi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fastapi_endpoint
39 changes: 39 additions & 0 deletions extendable_fastapi/models/fastapi_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from typing import List

from starlette.middleware import Middleware

from odoo import models

from odoo.addons.extendable.registry import _extendable_registries_database

from extendable import context


class ExtendableContextManagerMiddleware(object):
def __init__(self, app, dbname):
self.app = app
self.dbname = dbname

async def __call__(self, scope, receive, send):
registry = _extendable_registries_database.get(self.dbname, {})
token = context.extendable_registry.set(registry)
try:
response = await self.app(scope, receive, send)
finally:
context.extendable_registry.reset(token)
return response


class FastapiEndpoint(models.Model):

_inherit = "fastapi.endpoint"

def _get_fastapi_app_middlewares(self) -> List[Middleware]:
middlewares = super()._get_fastapi_app_middlewares()
middlewares.append(
(ExtendableContextManagerMiddleware, {"dbname": self.env.cr.dbname})
)
return middlewares
1 change: 1 addition & 0 deletions extendable_fastapi/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Laurent Mignon <laurent.mignon@acsone.eu> (https://acsone.eu)
5 changes: 5 additions & 0 deletions extendable_fastapi/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This addon is a technical addon used to allows the use of
`extendable <https://pypi.org/project/extendable/>`_
classes in the implementation of your fastapi endpoint handlers. It also
allows you to use `extendable_pydantic <https://pypi.org/project/extendable_pydantic/>`_
models when defining your endpoint handlers request and response models.
Binary file added extendable_fastapi/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading