[MIG] dbfilter_from_header: Migration to 8.0
Signed-off-by: Carmen Bianca Bakker <carmen@coopiteasy.be>pull/2425/head
parent
4a0df4dea5
commit
a5d13cbba9
|
@ -3,6 +3,7 @@
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
|
# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
|
||||||
|
# This module copyright (C) 2014 ACSONE SA/NV (<http://acsone.eu>).
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -19,13 +20,19 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import re
|
import re
|
||||||
from openerp.addons.web.controllers import main as web_main
|
from openerp import http
|
||||||
|
|
||||||
db_list_org = web_main.db_list
|
db_filter_org = http.db_filter
|
||||||
|
|
||||||
def db_list(req, force=False):
|
|
||||||
db_filter = req.httprequest.environ.get('HTTP_X_OPENERP_DBFILTER', '.*')
|
|
||||||
dbs = db_list_org(req, force=force)
|
|
||||||
return [db for db in dbs if re.match(db_filter, db)]
|
|
||||||
|
|
||||||
web_main.db_list = db_list
|
def db_filter(dbs, httprequest=None):
|
||||||
|
dbs = db_filter_org(dbs, httprequest)
|
||||||
|
httprequest = httprequest or http.request.httprequest
|
||||||
|
db_filter_hdr = \
|
||||||
|
httprequest.environ.get('HTTP_X_ODOO_DBFILTER') or \
|
||||||
|
httprequest.environ.get('HTTP_X_OPENERP_DBFILTER')
|
||||||
|
if db_filter_hdr:
|
||||||
|
dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
|
||||||
|
return dbs
|
||||||
|
|
||||||
|
http.db_filter = db_filter
|
||||||
|
|
|
@ -19,14 +19,15 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
{
|
{
|
||||||
"name" : "dbfilter_from_header",
|
"name": "dbfilter_from_header",
|
||||||
"version" : "1.0",
|
"version": "8.0.1.0.0",
|
||||||
"author" : "Therp BV",
|
"author": "Therp BV,Odoo Community Association (OCA)",
|
||||||
|
"license": "AGPL-3",
|
||||||
"complexity": "normal",
|
"complexity": "normal",
|
||||||
"description": """
|
"description": """
|
||||||
This addon lets you pass a dbfilter as a HTTP header.
|
This addon lets you pass a dbfilter as a HTTP header.
|
||||||
|
|
||||||
This is interesting for setups where database names can't be mapped to
|
This is interesting for setups where database names can't be mapped to
|
||||||
proxied host names.
|
proxied host names.
|
||||||
|
|
||||||
In nginx, use
|
In nginx, use
|
||||||
|
@ -34,11 +35,11 @@
|
||||||
|
|
||||||
The addon has to be loaded as server-wide module.
|
The addon has to be loaded as server-wide module.
|
||||||
""",
|
""",
|
||||||
"category" : "Tools",
|
"category": "Tools",
|
||||||
"depends" : [
|
"depends": [
|
||||||
'web',
|
'web',
|
||||||
],
|
],
|
||||||
"data" : [
|
"data": [
|
||||||
],
|
],
|
||||||
"js": [
|
"js": [
|
||||||
],
|
],
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
],
|
],
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"external_dependencies" : {
|
"external_dependencies": {
|
||||||
'python' : [],
|
'python': [],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
Loading…
Reference in New Issue