[storm] Using Storm with Django

Gustavo Niemeyer gustavo at niemeyer.net
Thu Jul 31 13:36:34 BST 2008


Hey James,

> As hinted at earlier, I've been working on integrating Storm with
> Django.  I've put a branch up on Launchpad, which can be downloaded
> with:
>
>    bzr branch lp:~jamesh/storm/django-support storm

Wow, nice!

(...)
> 4. In your view code, you can get a store with:
>    from storm.django.stores import get_store
>    store = get_store("name")
>
> Then use the store as you would normally.  This uses the existing
> zstorm code, so you get long lived per-thread connections and
> integration with the Zope global transaction manager (and the
> middleware causes the commits to occur at the right places).

Cool.

> One thing to note is that the ZopeTransactionMiddleware class will not
> commit on all requests.  If the request is a GET or HEAD, then the
> transaction will be aborted instead (since the request should be
> idempotent).  This policy can be turned off by setting
> STORM_COMMIT_SAFE_METHODS to True.

I suspect this might trick people, since even though this policy
makes sense, it's not always the case that it's entirely safe to
not commit (e.g. sessions might be changed on read requests).

> The changes to be able to use the storm.zope.zstorm code with a cut
> down Zope are available in my lp:~jamesh/storm/require-less-zope
> branch, which is essentially the same as the patch I posted earlier
> with a change to run most of the zstorm tests when in this
> configuration.  This section of the changes is already up for review,
> even though the remainder is still in progress.

Ok, we have to check out some pending branches in Storm.

> One thing this branch does not help you do is to use some of the
> existing Django infrastructure with Storm classes.  At a minimum I'd
> like to get the Django admin interface working with Storm classes.

That'd be awesome!  Please let us know how it goes.

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the storm mailing list