librelist archives

« back to archive

Re: [flask] Understand piece of code

Re: [flask] Understand piece of code

From:
Mark Teisman
Date:
2013-07-31 @ 20:50
Hi there, 
The short answer is that the model_form class probably specifies a 
__call__ method. The __call__ method is called when a model instance is 
"called" as a function. It accepts arguments just like functions do.
MyForm(request.form, model)
then is shorthand for
MyForm.__call__(request.form, model)
the model_form class could define the __call__ method like this:
class model_form(object):    __call__(self, form_instance, 
model_instance):        # do something 		 	   		  

Re: [flask] Understand piece of code

From:
Julien Debaru
Date:
2013-08-01 @ 15:59
Hi,

Thank your for your answers.
I think i better understand now.