summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2014-04-29 16:05:11 +0200
committerFabien Meghazi <fme@openerp.com>2014-04-29 16:05:11 +0200
commitbbb4ae3d42bc843230f3a69852b70d1d17f622ef (patch)
tree49a7b35c7c54e36cb6228931cb94b2a9a7a3af7a
parent2680f382ad7c29dba81f98e29c8f6b68d3d38609 (diff)
parent22480561670857e74a980b7a4b13d64eff9a8781 (diff)
[FIX] routing_type meta info was populated too late in routing_map()
Thus not allowing usage in tests bzr revid: fme@openerp.com-20140429140511-dktftjo1yb9f3jrj
-rw-r--r--openerp/http.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/openerp/http.py b/openerp/http.py
index c9181d2c211..83bcf81575f 100644
--- a/openerp/http.py
+++ b/openerp/http.py
@@ -601,6 +601,16 @@ class ControllerType(type):
# flag old-style methods with req as first argument
for k, v in attrs.items():
if inspect.isfunction(v) and hasattr(v, 'original_func'):
+ # Set routing type on original functions
+ routing_type = v.routing.get('type')
+ parent = [claz for claz in bases if isinstance(claz, ControllerType) and hasattr(claz, k)]
+ parent_routing_type = getattr(parent[0], k).original_func.routing_type if parent else routing_type or 'http'
+ if routing_type is not None and routing_type is not parent_routing_type:
+ routing_type = parent_routing_type
+ _logger.warn("Subclass re-defines <function %s.%s.%s> with different type than original."
+ " Will use original type: %r" % (cls.__module__, cls.__name__, k, parent_routing_type))
+ v.original_func.routing_type = routing_type or parent_routing_type
+
spec = inspect.getargspec(v.original_func)
first_arg = spec.args[1] if len(spec.args) >= 2 else None
if first_arg in ["req", "request"]:
@@ -660,15 +670,6 @@ def routing_map(modules, nodb_only, converters=None):
for claz in reversed(mv.im_class.mro()):
fn = getattr(claz, mv.func_name, None)
if fn and hasattr(fn, 'routing') and fn not in methods_done:
- fn_type = fn.routing.get('type')
- if not routing_type:
- routing_type = fn_type
- else:
- if fn_type and routing_type != fn_type:
- _logger.warn("Subclass re-defines <function %s.%s> with different type than original."
- " Will use original type: %r", fn.__module__, fn.__name__, routing_type)
- fn.routing['type'] = routing_type
- fn.original_func.routing_type = routing_type
methods_done.append(fn)
routing.update(fn.routing)
if not nodb_only or nodb_only == (routing['auth'] == "none"):