mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 09:32:07 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright 2023 ACSONE SA/NV
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL).
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from odoo.http import _dispatchers
|
||||
|
||||
from odoo.addons.extendable.registry import _extendable_registries_database
|
||||
from odoo.addons.fastapi.fastapi_dispatcher import (
|
||||
FastApiDispatcher as BaseFastApiDispatcher,
|
||||
)
|
||||
|
||||
from extendable import context
|
||||
|
||||
|
||||
# Inherit from last registered fastapi dispatcher
|
||||
# This handles multiple overload of dispatchers
|
||||
class FastApiDispatcher(_dispatchers.get("fastapi", BaseFastApiDispatcher)):
|
||||
routing_type = "fastapi"
|
||||
|
||||
def dispatch(self, endpoint, args):
|
||||
with self._manage_extendable_context():
|
||||
return super().dispatch(endpoint, args)
|
||||
|
||||
@contextmanager
|
||||
def _manage_extendable_context(self):
|
||||
env = self.request.env
|
||||
registry = _extendable_registries_database.get(env.cr.dbname, {})
|
||||
token = context.extendable_registry.set(registry)
|
||||
try:
|
||||
response = yield
|
||||
finally:
|
||||
context.extendable_registry.reset(token)
|
||||
return response
|
||||
Loading…
Add table
Add a link
Reference in a new issue