[MERGE] changes required for the "import hook" commit in the server.

bzr revid: vmt@openerp.com-20120118104708-wqa2fam7qnaw3jdk
This commit is contained in:
Vo Minh Thu
2012-01-18 11:47:08 +01:00
3 changed files with 28 additions and 27 deletions
+7 -6
View File
@@ -407,7 +407,7 @@ class Root(object):
only used in case the list of databases is requested
by the server, will be filtered by this pattern
"""
def __init__(self, options):
def __init__(self, options, openerp_addons_namespace=True):
self.root = '/web/webclient/home'
self.config = options
@@ -421,7 +421,7 @@ class Root(object):
self.session_cookie = 'sessionid'
self.addons = {}
static_dirs = self._load_addons()
static_dirs = self._load_addons(openerp_addons_namespace)
if options.serve_static:
self.dispatch = werkzeug.wsgi.SharedDataMiddleware(
self.dispatch, static_dirs)
@@ -475,15 +475,13 @@ class Root(object):
return response(environ, start_response)
def _load_addons(self):
def _load_addons(self, openerp_addons_namespace=True):
"""
Loads all addons at the specified addons path, returns a mapping of
static URLs to the corresponding directories
"""
statics = {}
for addons_path in self.config.addons_path:
if addons_path not in sys.path:
sys.path.insert(0, addons_path)
for module in os.listdir(addons_path):
if module not in addons_module:
manifest_path = os.path.join(addons_path, module, '__openerp__.py')
@@ -492,7 +490,10 @@ class Root(object):
manifest = ast.literal_eval(open(manifest_path).read())
manifest['addons_path'] = addons_path
_logger.info("Loading %s", module)
m = __import__(module)
if openerp_addons_namespace:
m = __import__('openerp.addons.' + module)
else:
m = __import__(module)
addons_module[module] = m
addons_manifest[module] = manifest
statics['/%s/static' % module] = path_static
+20 -20
View File
@@ -23,8 +23,8 @@ try:
except ImportError:
xlwt = None
import web.common
openerpweb = web.common.http
from .. import common
openerpweb = common.http
#----------------------------------------------------------
# OpenERP Web web Controllers
@@ -259,7 +259,7 @@ class WebClient(openerpweb.Controller):
@openerpweb.jsonrequest
def version_info(self, req):
return {
"version": web.common.release.version
"version": common.release.version
}
class Proxy(openerpweb.Controller):
@@ -392,7 +392,7 @@ class Session(openerpweb.Controller):
@openerpweb.jsonrequest
def authenticate(self, req, db, login, password, base_location=None):
wsgienv = req.httprequest.environ
release = web.common.release
release = common.release
env = dict(
base_location=base_location,
HTTP_HOST=wsgienv['HTTP_HOST'],
@@ -486,8 +486,8 @@ class Session(openerpweb.Controller):
no group by should be performed)
"""
context, domain = eval_context_and_domain(req.session,
web.common.nonliterals.CompoundContext(*(contexts or [])),
web.common.nonliterals.CompoundDomain(*(domains or [])))
common.nonliterals.CompoundContext(*(contexts or [])),
common.nonliterals.CompoundDomain(*(domains or [])))
group_by_sequence = []
for candidate in (group_by_seq or []):
@@ -847,14 +847,14 @@ class DataSet(openerpweb.Controller):
def _call_kw(self, req, model, method, args, kwargs):
for i in xrange(len(args)):
if isinstance(args[i], web.common.nonliterals.BaseContext):
if isinstance(args[i], common.nonliterals.BaseContext):
args[i] = req.session.eval_context(args[i])
elif isinstance(args[i], web.common.nonliterals.BaseDomain):
elif isinstance(args[i], common.nonliterals.BaseDomain):
args[i] = req.session.eval_domain(args[i])
for k in kwargs.keys():
if isinstance(kwargs[k], web.common.nonliterals.BaseContext):
if isinstance(kwargs[k], common.nonliterals.BaseContext):
kwargs[k] = req.session.eval_context(kwargs[k])
elif isinstance(kwargs[k], web.common.nonliterals.BaseDomain):
elif isinstance(kwargs[k], common.nonliterals.BaseDomain):
kwargs[k] = req.session.eval_domain(kwargs[k])
return getattr(req.session.model(model), method)(*args, **kwargs)
@@ -933,7 +933,7 @@ class View(openerpweb.Controller):
xml = self.transform_view(arch, session, evaluation_context)
else:
xml = ElementTree.fromstring(arch)
fvg['arch'] = web.common.xml2json.from_elementtree(xml, preserve_whitespaces)
fvg['arch'] = common.xml2json.from_elementtree(xml, preserve_whitespaces)
for field in fvg['fields'].itervalues():
if field.get('views'):
@@ -1024,7 +1024,7 @@ class View(openerpweb.Controller):
def parse_domain(domain, session):
""" Parses an arbitrary string containing a domain, transforms it
to either a literal domain or a :class:`web.common.nonliterals.Domain`
to either a literal domain or a :class:`common.nonliterals.Domain`
:param domain: the domain to parse, if the domain is not a string it
is assumed to be a literal domain and is returned as-is
@@ -1037,11 +1037,11 @@ def parse_domain(domain, session):
return ast.literal_eval(domain)
except ValueError:
# not a literal
return web.common.nonliterals.Domain(session, domain)
return common.nonliterals.Domain(session, domain)
def parse_context(context, session):
""" Parses an arbitrary string containing a context, transforms it
to either a literal context or a :class:`web.common.nonliterals.Context`
to either a literal context or a :class:`common.nonliterals.Context`
:param context: the context to parse, if the context is not a string it
is assumed to be a literal domain and is returned as-is
@@ -1053,7 +1053,7 @@ def parse_context(context, session):
try:
return ast.literal_eval(context)
except ValueError:
return web.common.nonliterals.Context(session, context)
return common.nonliterals.Context(session, context)
class ListView(View):
_cp_path = "/web/listview"
@@ -1117,10 +1117,10 @@ class SearchView(View):
@openerpweb.jsonrequest
def save_filter(self, req, model, name, context_to_save, domain):
Model = req.session.model("ir.filters")
ctx = web.common.nonliterals.CompoundContext(context_to_save)
ctx = common.nonliterals.CompoundContext(context_to_save)
ctx.session = req.session
ctx = ctx.evaluate()
domain = web.common.nonliterals.CompoundDomain(domain)
domain = common.nonliterals.CompoundDomain(domain)
domain.session = req.session
domain = domain.evaluate()
uid = req.session._uid
@@ -1135,10 +1135,10 @@ class SearchView(View):
@openerpweb.jsonrequest
def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''):
ctx = web.common.nonliterals.CompoundContext(context_to_save)
ctx = common.nonliterals.CompoundContext(context_to_save)
ctx.session = req.session
ctx = ctx.evaluate()
domain = web.common.nonliterals.CompoundDomain(domain)
domain = common.nonliterals.CompoundDomain(domain)
domain.session = req.session
domain = domain.evaluate()
@@ -1584,7 +1584,7 @@ class Reports(View):
report_srv = req.session.proxy("report")
context = req.session.eval_context(
web.common.nonliterals.CompoundContext(
common.nonliterals.CompoundContext(
req.context or {}, action[ "context"]))
report_data = {}
+1 -1
View File
@@ -86,7 +86,7 @@ if __name__ == "__main__":
else:
logging.basicConfig(level=getattr(logging, options.log_level.upper()))
app = web.common.http.Root(options)
app = web.common.http.Root(options, openerp_addons_namespace=False)
if options.proxy_mode:
app = werkzeug.contrib.fixers.ProxyFix(app)