forked from acsone/click-odoo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Arnold
committed
Dec 19, 2019
1 parent
d7eb61e
commit fb7a47f
Showing
32 changed files
with
276 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# `dodoo profile` Component | ||
|
||
## Abstract | ||
|
||
`dodoo profile` subcommand ist a shim for py-spy **sampling** profiler that can | ||
be run with negilgible overhead penalty on production processes, without anxiety. | ||
|
||
## Spec | ||
|
||
see manpage | ||
|
||
|
||
<div align="center"> | ||
<div> | ||
<a href="https://xoe.solutions"> | ||
<img width="100" src="https://erp.xoe.solutions/logo.png" alt="XOE Corp. SAS"> | ||
</a> | ||
</div> | ||
<p> | ||
<sub>Currently, folks <a href="https://github.com/xoe-labs/">@xoe-labs</a> try to keep up with their task to maintain this.</sub> | ||
</p> | ||
<p> | ||
<sub>If you're the kind of person, willing to sponsor open source projects, consider sending some spare XLM banana to <code>blaggacao*keybase.io</code></sub> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ============================================================================= | ||
# Created By : David Arnold | ||
# Part of : xoe-labs/dodoo | ||
# ============================================================================= | ||
"""This module implements an interface to the odoo namespace. | ||
Hence, maintainers have a single source of truth of it's usage. | ||
Consequent lazy loading of patchable properties ensures patchability. | ||
For consistency, never access the odoo namespace directly.""" | ||
|
||
from importlib import import_module | ||
|
||
from dodoo.patchers import PatchableProperty as PProp | ||
|
||
|
||
class Session: | ||
def __init__(self): | ||
self._r = import_module("odoo.http") | ||
|
||
@property | ||
def SessionClass(self): | ||
return self._r.OpenERPSession | ||
|
||
|
||
class Patchable: | ||
|
||
# ############################# | ||
# Index of patched namespaces # | ||
# ############################# | ||
# | ||
# odoo.http | ||
# | ||
# ############################# | ||
|
||
# odoo.http | ||
session_gc = PProp("odoo.http:session_gc") | ||
session_store = PProp("odoo.http:Root.session_store") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ============================================================================= | ||
# Created By : David Arnold | ||
# Part of : xoe-labs/dodoo | ||
# ============================================================================= | ||
"""This module implements odoo asgi middleware to provide an Odoo Environment | ||
for http and websocket transport""" | ||
|
||
from starlette.types import ASGIApp, Receive, Scope, Send | ||
|
||
import contextvars | ||
|
||
scope = contextvars.ContextVar("scope") | ||
|
||
|
||
class GlobalScopeAccessorMiddleware: | ||
""" | ||
A middleware class that exports scope to arbitrarily access it. | ||
""" | ||
|
||
def __init__(self, app: ASGIApp) -> None: | ||
self.app = app | ||
|
||
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: | ||
token = scope.set(scope) | ||
await self.app(scope, receive, send) | ||
scope.reset(token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# ============================================================================= | ||
# Created By : David Arnold | ||
# Part of : xoe-labs/dodoo | ||
# ============================================================================= | ||
"""This module implements a monkey patcher scoped for use with dodoo run""" | ||
|
||
from dodoo_run.middleware.globalscope import scope | ||
|
||
from dodoo.interfaces import odoo | ||
from dodoo.patchers import BasePatcher | ||
|
||
from ..interfaces import _odoo | ||
from ..sessions import ClientSessionStore | ||
|
||
|
||
class OdooClientSessionStore(ClientSessionStore): | ||
"""Modified Odoo client session store. Provides the path interface for | ||
session.save_request_data / session.load_request_data methods of the | ||
Odoo Session Class. | ||
""" | ||
|
||
def __init__(self, session_class=_odoo.Session().SessionClass, **kwargs): | ||
super().__init__(**kwargs) | ||
self.path = odoo.Config().session_dir() | ||
|
||
|
||
# Inheriting order important | ||
class SessionStoragePatcher(_odoo.Patchable, BasePatcher): | ||
@staticmethod | ||
def session_gc(session_store): | ||
return | ||
|
||
def session_store(self): | ||
return OdooClientSessionStore(scope=scope.get()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ============================================================================= | ||
# Created By : David Arnold | ||
# Part of : xoe-labs/dodoo | ||
# ============================================================================= | ||
"""This module implements the common data accessors shared among servers""" | ||
|
||
from starlette.datastructures import Secret | ||
|
||
import dodoo | ||
|
||
SessionDataKey = "session_data" | ||
|
||
|
||
class SessionSecret(Secret): | ||
""" | ||
Resolves to a string value that should not be revealed in tracebacks etc. | ||
You should cast the value to `str` at the point it is required. | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def __repr__(self) -> str: | ||
class_name = self.__class__.__name__ | ||
return f"{class_name}('**********')" | ||
|
||
def __str__(self) -> str: | ||
return dodoo.dodoo_config.Odoo.Sec.session_encryption_key | ||
|
||
|
||
SessionMiddlewareArgs = dict( | ||
sekret_key=SessionSecret(), session_cookie=SessionDataKey, https_only=True | ||
) | ||
GZipMiddlewareArgs = dict(minimum_size=500) | ||
|
||
|
||
def resolve_devcert(): | ||
ssl_keyfile = dodoo.dodoo_config.Odoo.ssl_keyfile | ||
ssl_certfile = dodoo.dodoo_config.Odoo.ssl_certfile | ||
assert ssl_keyfile and ssl_certfile | ||
return dict(ssl_keyfile=str(ssl_keyfile), ssl_certfile=str(ssl_certfile)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.