[IMP] Cleaned some more http.py, removed 'debug' handling and put it in the controller serving the home page
bzr revid: nicolas.vanhoren@openerp.com-20130724073624-uhshc0cn2m3rs7iq
This commit is contained in:
parent
e81708ba35
commit
761ba75055
|
@ -296,13 +296,13 @@ def manifest_glob(extension, addons=None, db=None, include_remotes=False):
|
|||
r.append((path, fs2web(path[len(addons_path):])))
|
||||
return r
|
||||
|
||||
def manifest_list(extension, mods=None, db=None):
|
||||
def manifest_list(extension, mods=None, db=None, debug=False):
|
||||
""" list ressources to load specifying either:
|
||||
mods: a comma separated string listing modules
|
||||
db: a database name (return all installed modules in that database)
|
||||
"""
|
||||
files = manifest_glob(extension, addons=mods, db=db, include_remotes=True)
|
||||
if not request.debug:
|
||||
if not debug:
|
||||
path = '/web/webclient/' + extension
|
||||
if mods is not None:
|
||||
path += '?' + urllib.urlencode({'mods': mods})
|
||||
|
@ -540,8 +540,10 @@ class Home(http.Controller):
|
|||
if redir:
|
||||
return redirect_with_hash(redir)
|
||||
|
||||
js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in manifest_list('js', db=db))
|
||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in manifest_list('css', db=db))
|
||||
debug = "debug" in kw
|
||||
|
||||
js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in manifest_list('js', db=db, debug=debug))
|
||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in manifest_list('css', db=db, debug=debug))
|
||||
|
||||
r = html_template % {
|
||||
'js': js,
|
||||
|
|
|
@ -85,10 +85,6 @@ class WebRequest(object):
|
|||
|
||||
:class:`~collections.Mapping` of context values for the current request
|
||||
|
||||
.. attribute:: debug
|
||||
|
||||
``bool``, indicates whether the debug mode is active on the client
|
||||
|
||||
.. attribute:: db
|
||||
|
||||
``str``, the name of the database linked to the current request. Can be ``None``
|
||||
|
@ -112,7 +108,6 @@ class WebRequest(object):
|
|||
self._cr_cm = None
|
||||
self._cr = None
|
||||
self.func_request_type = None
|
||||
self.debug = self.httprequest.args.get('debug', False) is not False
|
||||
with set_request(self):
|
||||
self.db = self.session.db or db_monodb()
|
||||
# set db/uid trackers - they're cleaned up at the WSGI
|
||||
|
@ -304,8 +299,6 @@ class JsonRequest(WebRequest):
|
|||
error = None
|
||||
|
||||
try:
|
||||
#if _logger.isEnabledFor(logging.DEBUG):
|
||||
# _logger.debug("--> %s.%s\n%s", func.im_class.__name__, func.__name__, pprint.pformat(self.jsonrequest))
|
||||
response['id'] = self.jsonrequest.get('id')
|
||||
response["result"] = self._call_function(**self.params)
|
||||
except AuthenticationError, e:
|
||||
|
@ -327,9 +320,6 @@ class JsonRequest(WebRequest):
|
|||
if error:
|
||||
response["error"] = error
|
||||
|
||||
if _logger.isEnabledFor(logging.DEBUG):
|
||||
_logger.debug("<--\n%s", pprint.pformat(response))
|
||||
|
||||
if self.jsonp:
|
||||
# If we use jsonp, that's mean we are called from another host
|
||||
# Some browser (IE and Safari) do no allow third party cookies
|
||||
|
@ -394,7 +384,7 @@ class HttpRequest(WebRequest):
|
|||
def __init__(self, *args):
|
||||
super(HttpRequest, self).__init__(*args)
|
||||
params = dict(self.httprequest.args)
|
||||
ex = set(["session_id", "debug"])
|
||||
ex = set(["session_id"])
|
||||
for k in params.keys():
|
||||
if k in ex:
|
||||
del params[k]
|
||||
|
@ -409,7 +399,6 @@ class HttpRequest(WebRequest):
|
|||
akw[key] = value
|
||||
else:
|
||||
akw[key] = type(value)
|
||||
#_logger.debug("%s --> %s.%s %r", self.httprequest.func, func.im_class.__name__, func.__name__, akw)
|
||||
try:
|
||||
r = self._call_function(**self.params)
|
||||
except werkzeug.exceptions.HTTPException, e:
|
||||
|
@ -426,10 +415,6 @@ class HttpRequest(WebRequest):
|
|||
else:
|
||||
if not r:
|
||||
r = werkzeug.wrappers.Response(status=204) # no content
|
||||
if isinstance(r, (werkzeug.wrappers.BaseResponse, werkzeug.exceptions.HTTPException)):
|
||||
_logger.debug('<-- %s', r)
|
||||
else:
|
||||
_logger.debug("<-- size: %s", len(r))
|
||||
return r
|
||||
|
||||
def make_response(self, data, headers=None, cookies=None):
|
||||
|
|
Loading…
Reference in New Issue