[IMP] dbfilter_from_header: black, isort
Signed-off-by: Carmen Bianca Bakker <carmen@coopiteasy.be>pull/2425/head
parent
9c725ac160
commit
723ff14c39
|
@ -1,2 +1 @@
|
||||||
|
|
||||||
from . import override
|
from . import override
|
||||||
|
|
|
@ -6,16 +6,13 @@
|
||||||
{
|
{
|
||||||
"name": "dbfilter_from_header",
|
"name": "dbfilter_from_header",
|
||||||
"summary": "Filter databases with HTTP headers",
|
"summary": "Filter databases with HTTP headers",
|
||||||
"version": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"website": "https://github.com/OCA/server-tools",
|
"website": "https://github.com/OCA/server-tools",
|
||||||
"author": "Therp BV, "
|
"author": "Therp BV, " "Odoo Community Association (OCA)",
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"complexity": "normal",
|
"complexity": "normal",
|
||||||
"category": "Tools",
|
"category": "Tools",
|
||||||
"depends": [
|
"depends": ["web"],
|
||||||
'web',
|
|
||||||
],
|
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
'installable': True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.tools import config
|
from odoo.tools import config
|
||||||
|
|
||||||
|
@ -14,14 +15,15 @@ db_filter_org = http.db_filter
|
||||||
def db_filter(dbs, httprequest=None):
|
def db_filter(dbs, httprequest=None):
|
||||||
dbs = db_filter_org(dbs, httprequest)
|
dbs = db_filter_org(dbs, httprequest)
|
||||||
httprequest = httprequest or http.request.httprequest
|
httprequest = httprequest or http.request.httprequest
|
||||||
db_filter_hdr = httprequest.environ.get('HTTP_X_ODOO_DBFILTER')
|
db_filter_hdr = httprequest.environ.get("HTTP_X_ODOO_DBFILTER")
|
||||||
if db_filter_hdr:
|
if db_filter_hdr:
|
||||||
dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
|
dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
|
||||||
return dbs
|
return dbs
|
||||||
|
|
||||||
|
|
||||||
if config.get('proxy_mode') and \
|
if config.get("proxy_mode") and "dbfilter_from_header" in config.get(
|
||||||
'dbfilter_from_header' in config.get('server_wide_modules'):
|
"server_wide_modules"
|
||||||
|
):
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
_logger.info('monkey patching http.db_filter')
|
_logger.info("monkey patching http.db_filter")
|
||||||
http.db_filter = db_filter
|
http.db_filter = db_filter
|
||||||
|
|
Loading…
Reference in New Issue