[Grok-dev] Re: STORM howto
Wichert Akkerman
wichert at wiggy.net
Fri Mar 14 05:22:41 EDT 2008
Previously Christian Klinger wrote:
> Sebastian Ware schrieb:
> >Do I add nva.stormcontainer in setup.py in order to fetch this egg? I
> >would like to try it.
> >
>
> Yes this should do it. Hopefully...
>
> >Also, is there any way I can control the commits? I am basically doing:
> >
> >for obj in objlist:
> > ormContainer['id'] = obj
>
> In the stormcontainer there is a __setitem__ which is responsible for
> the insert.
>
> def __setitem__(self, name, item):
> store = getUtility(IZStorm).get(self.getStoreUtilityName())
> store.add(item)
> transaction.commit()
>
> The transaction.commit() fires also an rdb.commit. This means on every
> insert there is a commit.
>
> But maybe it is possible to delete the transaction.commit() in
> __setitem__, and rely on zopes transaction.commit.?
I do not think any library or framework should ever do a commit itself.
You should hook properly into the zope transaction manager. Any
premature commit can result in inconsistent or erroneous data in your
database. And reducing the number of commits will have a huge impact on
performance.
Wichert.
--
Wichert Akkerman <wichert at wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
More information about the Grok-dev
mailing list