[storm] blog post
James Henstridge
james at jamesh.id.au
Fri Jul 20 08:09:58 BST 2007
On 20/07/07, Eugene Van den Bulke <eugene.vandenbulke at gmail.com> wrote:
> not sure if that popped up on the storm-brain-power radar but could be
> interesting to step in
> http://renesd.blogspot.com/2007/07/my-issues-with-python-orms.html
In answer to your first point about "Python ORMs break with multiple
processes.", I'd argue that that is not the case for Storm.
Storm does cache data within a single transaction, but those caches
are cleared on transaction boundaries. With full transaction
isolation, you are effectively working with a snapshot of the
database, so this is a safe assumption to make (the compromise is that
you may need to retry a transaction if it conflicts with a concurrent
one).
For the second point "Constructors are limited to creation", allowing
the constructor to return existing rows from the database would mean
that the class needs to be bound to a particular database connection.
One of the aims of Storm is to allow you to talk to multiple databases
that share the same schema, so linking the class to a connection is
not desirable.
Your third point seems like a confusing API to me. The general
pattern for most ORMs is for classes to represent tables and instances
to represent rows of the associated tables. Performing operations on
the table using an instance seems bizarre. I'd expect to see a class
method (or some other function that takes the class as an argument).
Note that you can use Storm result sets for various operations without
using the actual instances:
# set the name of all people with active=3 to "Active person"
>>> result = store.find(Person, active=3)
>>> result.set(name='Active person')
# Delete "Joe"
>>> store.find(Person, name="Joe").remove()
# Get the names of all people with active=3:
>>> store.find(Person, active=3).values(Person.name)
[...]
For your fourth point, if you have a dictionary mapping field names to
values, and a function that expects field names as keyword arguments,
why not use the "**vars" syntax?
James.
More information about the storm
mailing list