Commit 80535a2c authored by M. de Verteuil's avatar M. de Verteuil
Browse files

A less naive strategy for getting view closure var

 - Now handles views decorated with functions that have positional arguments
 - Searches for a types.FunctionType argument in the closure, rather than assuming the first
   argument is the view.
parent 1a7c0c32
......@@ -35,10 +35,16 @@ def closure_n_code(func):
def get_closure_var(func, name=None):
unwrap = closure_n_code(func)
i = 0
if name:
i = unwrap.code.co_freevars.index(name)
return unwrap.closure[i].cell_contents
index = unwrap.code.co_freevars.index(name)
return unwrap.closure[index].cell_contents
for closure_var in unwrap.closure:
if isinstance(closure_var.cell_contents, types.FunctionType):
return closure_var.cell_contents
return None
def wrapper_to_func(wrapper):
noms = wrapper.http_method_names
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment