[FIX] website: endpoint_is_enumerable

old version of @website.route would wrap the base method within a
decorator, and endpoint_is_enumerable had to dig into the decorator to
get the original function (and be able to inspect it).

@website.route has been simplified and no longer wraps the function,
just adds a pair of attributes to it (and so does the base
@http.route), so don't dig into anymore, inspect rule.endpoint
directly.

bzr revid: xmo@openerp.com-20131202102525-8jsondrr1649c8t8
This commit is contained in:
Xavier Morel 2013-12-02 11:25:25 +01:00
parent 2ce50aeb2f
commit a108af5cb8
1 changed files with 1 additions and 10 deletions

View File

@ -299,16 +299,7 @@ class website(osv.osv):
:type rule: werkzeug.routing.Rule
:rtype: bool
"""
# apparently the decorator package makes getargspec work correctly
# on functions it decorates. That's not the case for
# @functools.wraps, so hack around to get the original function
# (and hope a single decorator was applied or we're hosed)
# FIXME: this is going to blow up if we want/need to use multiple @route (with various configurations) on a method
undecorated_func = rule.endpoint.func_closure[0].cell_contents
# If this is ever ported to py3, use signatures, it doesn't suck as much
spec = inspect.getargspec(undecorated_func)
spec = inspect.getargspec(rule.endpoint)
# if *args bail the fuck out, only dragons can live there
if spec.varargs: