[Chandler-dev] [Sum] The Great Architecture Discussion of 2007
mikeal at osafoundation.org
Tue Oct 9 20:19:55 PDT 2007
On Oct 9, 2007, at 6:58 PM, Phillip J. Eby wrote:
> Now, Hibernate is not available for Python (although I suppose you
> could make it so with JCC!) but it illustrates the point that is
> possible to separate things in this fashion. I believe there is at
> least one Python ORM that claims to be inspired by or to work like
> Hibernate, though. I also seem to recall that SQLAlchemy for
> Python also has a great deal of flexibility in mapping between
> different relational schemas, such that your code can deal with a
> logical schema rather than an actual one.
> There is also the possibility of just rolling Yet Another Python
> ORM, perhaps based on EIM. But these things don't matte as much as
> layering the application in such a way that it does not *care* how
> things actually get stored. Chandler's domain model objects should
> not be subclasses of a storage type, for example. (i.e., they
> should not be repository.Items).
I've spent a lot of time with Python ORM's so I thought I'd chime in
about a few things.
The primary ORM's I know of in python are SQLObject, SQLAlchemy ORM
and Django ORM.
Django ORM has a lot of extra web specific functionality in it that
we don't need or want.
SQLObject has a very easy to use API but customizing it's queries is
somewhere between difficult and impossible. I've seen some people
complain about scaling SQLObject but haven't used it enough to
comment on that myself.
TurboGears and Pylons both used to default to using SQLObject but
have now transitioned to SQLAlchemy. There is also some work in the
Django community to move the Django ORM over to using SQLAlchemy for
it's underlying database logic.
SQLAlchemy is a full featured db library which includes a SQL
expression language ( kind of like Hibernates HQL ), session
management, various db engines, and an ORM. The vanilla Alchemy ORM
is very verbose to use which has led a lot of people to design more
declarative libraries which use the alchemy ORM beneath. The most
popular right now is Elixir, http://elixir.ematia.de/ .
It's important to note that the alchemy ORM doesn't give you any way
to define custom marshalling or validation, that all has to be done
at a layer above the Alchemy ORM. Instances of Elixir classes are
just instances of Alchemy ORM classes, they don't try to do anything
in their area.
I've actually put a fair amount of time in to a layer above Alchemy's
ORM that provides you with custom field classes that you can use to
define your own marshalling and validation, simpler relationship
defintions, and a declarative layer that's as easy to use as
SQLObjects. Hopefully that will get released some time this month, I
meant to finish it weeks ago but various other projects got in the
way. I'll make sure to ping this list once I'm done.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the chandler-dev