[storm] Using Storm with Django
James Henstridge
james at jamesh.id.au
Thu Jul 31 13:44:49 BST 2008
On Thu, Jul 31, 2008 at 8:36 PM, Gustavo Niemeyer <gustavo at niemeyer.net> wrote:
> 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).
Yep. Changing the default is probably a good idea. This is the
policy we've been using with Launchpad for some time, but then we've
been fairly careful about not doing data modifying queries in GET
requests and our session database connection is in autocommit mode.
>> 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.
I'll keep the list posted on progress.
James.
More information about the storm
mailing list