MVC-type Framework in Python

J

John Roth

Andreas Pauley said:
Hi,

I'm interested in finding a nice way to develop applications that have
their business logic separated from the user interface (among other
things). This should enable easier maintenance, more flexibility and
(ideally) less development time for the app.

I've recently read about the Model-View-Controller design framework
(originally used in SmallTalk applications, or so it seems).
What python-specific tools/frameworks would you recommend that can be used
to implement MVC, or something similar (or perhaps better) than MVC?

I'm looking for something that can help build
interface-independent applications, with all logic in a central place.
There would typically be a GUI interface, character interface and
web-based interface, all accessing the same python logic.
The interfaces need not be python-specific. I would like, for example, to
have an existing PHP website access the same logic.

Another thing that would be nice is centralized validation.
If you change your validation rules in one place, the interfaces get to
know that without you having to change code on the interface.
Is it feasible to have python extract validation rules from the database
(e.g. a varchar(20) field) and pass that through to a gui interface that
would limit the amount of characters entered to 20? If you then change the
database field to a varchar(30), the change should be
detected without having to change any other code.

At the moment I'm just researching all of the different options for
designing/implementing applications (typically multi-user database-driven
apps), so I would appreciate any ideas. I assume some ideas have proven
themselves more feasible in production environments than others.

Well, first off every toolkit "supports" MVC in the sense that you
can do that pattern without an inordinate amount of pain or bending
the toolkit in ways it doesn't want to go.

What you want, though, is something a little different. You want a
layered architecture where you can install different UI front ends.
The best way I know of doing this is to create an abstract UI, and
then make each of the front ends a very thin facade on that UI. It's
an interesting design problem, especially since the typical user of each
of the UI's probably has different needs.

Part of the utility of the abstract UI is that you can write FIT fixtures
that will work with it directly so that you can test out the basic
application logic from the UI perspective without having to mess with
the last step of dealing with the screen rendering.

John Roth
 
A

Andreas Pauley

Hi,

I'm interested in finding a nice way to develop applications that have
their business logic separated from the user interface (among other
things). This should enable easier maintenance, more flexibility and
(ideally) less development time for the app.

I've recently read about the Model-View-Controller design framework
(originally used in SmallTalk applications, or so it seems).
What python-specific tools/frameworks would you recommend that can be used
to implement MVC, or something similar (or perhaps better) than MVC?

I'm looking for something that can help build
interface-independent applications, with all logic in a central place.
There would typically be a GUI interface, character interface and
web-based interface, all accessing the same python logic.
The interfaces need not be python-specific. I would like, for example, to
have an existing PHP website access the same logic.

Another thing that would be nice is centralized validation.
If you change your validation rules in one place, the interfaces get to
know that without you having to change code on the interface.
Is it feasible to have python extract validation rules from the database
(e.g. a varchar(20) field) and pass that through to a gui interface that
would limit the amount of characters entered to 20? If you then change the
database field to a varchar(30), the change should be
detected without having to change any other code.

At the moment I'm just researching all of the different options for
designing/implementing applications (typically multi-user database-driven
apps), so I would appreciate any ideas. I assume some ideas have proven
themselves more feasible in production environments than others.

Regards,
Andreas.
 
D

DH

I'm looking for something that can help build
interface-independent applications, with all logic in a central place.
There would typically be a GUI interface, character interface and
web-based interface, all accessing the same python logic.
The interfaces need not be python-specific. I would like, for example, to
have an existing PHP website access the same logic.

If you want a PHP website to be able to access it as well as a python
web or desktop application, you might try something like XML-RPC.
Some python examples:
http://www.pythonware.com/products/xmlrpc/
http://www.quixote.ca/qx/XmlRpcInterface
That last example uses the python-based Quixote web framework.

An alternative to XML-RPC is REST:
http://www.rexx.com/~dkuhlman/rest_howto.html

Is it feasible to have python extract validation rules from the database
(e.g. a varchar(20) field) and pass that through to a gui interface that
would limit the amount of characters entered to 20? If you then change the
database field to a varchar(30), the change should be
detected without having to change any other code.

Usually the validation is separate from the database. For example, how
would you specify that a field contains an email address or a phone number.

To make a quick web front-end to a database without any programming you
can use the PHP-based dadabik: http://www.dadabik.org/

But in python, see formencode & SQLobject:
http://formencode.org/
http://sqlobject.org/
 
F

F. GEIGER

I never felt comfortable with MVC. Since I read Holub's articles on
JavaWorld, I know how to do it *much* better. And to implement the concepts
shown there in Python is a breeze.

HTH
Franz GEIGER

P.S.: Don't have the URLs handy right now. Tell me if you can't find the
stuff. I'll then look for the URLs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top