Python Webpages

Ian Bicking ianb at colorstudy.com
Mon Apr 29 01:42:28 EDT 2002


On Sun, 2002-04-28 at 14:56, Gerhard Häring wrote:
> * Magnus <nixx at telia.com> [2002-04-28 18:59 +0000]:
> > [WebWare]
> > Another powerful (not yet final though) module is Middlekit which e.g. makes 
> > it easy to deploy a servlet that acts with some glueware to e.g. MySQL.
>  
> The more I think about it, the less I get the point of object-relational
> mappers like MiddleKit. Especially the ones that require you to rebuild
> the database schema every time you change the object schema. AFAIC
> MiddleKit falls into this category.
> 
> I think I'd prefer going either straight SQL with a dictionary mapper
> (pyPgSQL's PgResultSet has such a thing built in [1]) or using an object
> database like ZODB.
> 
> [1] in pyPgSQL, you can say, for example:
> cursor.execute("select id, name from test")
> print cursor.id, cursor.name
> print cursor['id'], cursor['name']
> print cursor[0], cursor[1]

The advantage of a more complete middleware is that you can add
functionality to the objects -- if you are creating MiddleKit objects
from the database schema, and you never add anything to those objects,
then it isn't nearly as interesting.

For instance, in some of my applications I associate images with rows,
but I don't store the images in the database, they are just on disk
somewhere.  My middle object has methods to manipulate that image, give
the URL for it, etc. -- and it has the same basic interface as database
access.  Or you might have a derived value -- say a case where you
require a user give an email, and they may also give their real name. 
So you change the name method to return their given name, if they
provided it, or their email if they didn't.

That sort of thing is the "middle" in middleware.  You don't need
something like MiddleKit to make your own middleware, of course -- you
can write your own objects that fetch rows from the database and provide
an interface to that information.  That's perfectly viable, but it tends
to feel a tad tedious.  You'll probably find yourself recreating
something like MiddleKit.

  Ian







More information about the Python-list mailing list