Data access from multiple code modules

Bruno Desthuilliers onurb at xiludom.gro
Thu Jul 13 10:41:34 EDT 2006


simon.hibbs at gmail.com wrote:
> Bruno Desthuilliers wrote:
> 
> 
>>Separating operations on data (model/controler) from GUI code (view).
>>The controler(s) have a reference on the model. The views have a
>>reference on the controler(s), and call on the controller to get data to
>>display or act on data.
> 
> 
> So I instantiate a Model object that handles all IO to the database.

FWIW, you may want to have a look at SQLAlchemy here.

> Next I instantiate a Controller object, passing it a reference to the
> Data/IO model object.

Yes. Note that you can have multiple controllers...

> Next I instantiate the display panel objects for
> the GUI, passing them references to the Controller object.

Yeps. Or the other way round - the gui instanciation can be the resp. of
the controller (which then passes itself to gui), but then this more
strongly ties the controller to a specific GUI and/or can force you into
a more strict controller <-> view protocol to abstract out any GUI
Toolkit specificities...

Now only having done web apps the past years, I may be a bit biased, so
you'd better look for other writings about the MVC stuff. Just note that
what was originaly the main bulk of the "controler" part (ie mapping
mouse and keyboard events to appropriate callbacks) is now mostly done
by the GUI Toolkit itself.

> The Controller object contains the logic for all the transformations I
> want to perform on the data.

Yes. And for data querying as well.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list