utils: allow to set an attribute on __init__ method to tell they need the request parameter

This commit is contained in:
Benjamin Dauvergne 2014-01-21 09:37:35 +01:00
parent fa24d2bba5
commit 0749e2205d
2 changed files with 3 additions and 0 deletions

View File

@ -38,6 +38,7 @@ class PasserelleRegisterForm(forms.Form):
choices=choices, initial=initial,
widget=widgets.CheckboxMultipleSelect,
required=False)
__init__.need_request = True
def save(self):

View File

@ -1,4 +1,6 @@
def callable_has_arg(method, arg):
if hasattr(method, 'need_'+arg):
return getattr(method, 'need_'+arg)
if hasattr(method, 'im_func'):
varnames = method.im_func.func_code.co_varnames
argcount = method.im_func.func_code.co_argcount