[IMP] Removed the openerp.addons prefix when loading modules
in stand-alone mode. Changed the import web.common to relative import (because the the import-hook in the server is not able to load modules with self-referential import). bzr revid: vmt@openerp.com-20120116104329-k68li2vul4b3j7ry
This commit is contained in:
parent
6ab102ec11
commit
1497062ba1
|
@ -403,7 +403,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
|
||||
|
||||
|
@ -417,7 +417,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)
|
||||
|
@ -471,7 +471,7 @@ 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
|
||||
|
@ -486,7 +486,10 @@ class Root(object):
|
|||
manifest = ast.literal_eval(open(manifest_path).read())
|
||||
manifest['addons_path'] = addons_path
|
||||
_logger.info("Loading %s", 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
|
||||
|
|
|
@ -19,8 +19,8 @@ from cStringIO import StringIO
|
|||
import babel.messages.pofile
|
||||
import werkzeug.utils
|
||||
|
||||
import web.common
|
||||
openerpweb = web.common.http
|
||||
from .. import common
|
||||
openerpweb = common.http
|
||||
|
||||
#----------------------------------------------------------
|
||||
# OpenERP Web web Controllers
|
||||
|
@ -249,7 +249,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):
|
||||
|
@ -382,7 +382,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'],
|
||||
|
@ -476,8 +476,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 []):
|
||||
|
@ -837,14 +837,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)
|
||||
|
@ -923,7 +923,7 @@ class View(openerpweb.Controller):
|
|||
xml = self.transform_view(arch, session, evaluation_context)
|
||||
else:
|
||||
xml = ElementTree.fromstring(arch)
|
||||
fvg['arch'] = web.common.xml2json.Xml2Json.convert_element(xml, preserve_whitespaces)
|
||||
fvg['arch'] = common.xml2json.Xml2Json.convert_element(xml, preserve_whitespaces)
|
||||
|
||||
for field in fvg['fields'].itervalues():
|
||||
if field.get('views'):
|
||||
|
@ -1014,7 +1014,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
|
||||
|
@ -1027,11 +1027,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
|
||||
|
@ -1043,7 +1043,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"
|
||||
|
@ -1107,10 +1107,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
|
||||
|
@ -1125,10 +1125,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()
|
||||
|
||||
|
@ -1554,7 +1554,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 = {}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue