[ZODB-Dev] misleading exception

dvd dvd at gnx.it
Wed Nov 9 10:34:20 EST 2005


On Sun, 2005-11-06 at 18:48 -0500, Tim Peters wrote:
> [dvd]
> > Hi all, I'm still working with savepoints and today I spend about tewo
> > hours to find an error, misleaded by a strange Exception
> 
> As Dieter said (thanks, Dieter!), the current transaction should always be
> explicitly committed or aborted before closing any Connection involved in
> the transaction.  ZODB tries to raise ConnectionStateError if you close a
> Connection without explicitly finalizing the transaction, but something
> about savepoints isn't getting caught here.  I'm not positive it _should_
> raise ConnectionStateError in this case.  But, if it doesn't, then it should
> guarantee to clean up all the bits left behind by the savepoint machinery.

Thank you for the answer
little by little I understand more details


> BTW, your code used a mixture of tabs and spaces for indentation.  That's a
> Bad Idea for code posted to a mailing list.  All-tabs or all-spaces works
> much better.  The Python and Zope projects' standards mandate 4-space
> indents (with no hard tab characters).

I use on top of my files
# vim: expandtab sw=4 ts=4 sts=4 foldmethod=indent:

but i forget a :retab
:)

> 
> >     fstorage = FileStorage.FileStorage(fname)
> >     db = DB(fstorage)
> >     try:
> >         conn = db.open()
> >         try:
> > 	    try:
> 
> That's an example of why mixing tabs with spaces sucks.  I can't know what
> that looks like in _your_ email reader, but in _mine_ it looks like both
> "try:" statements are indented the same.

you are right, sorry for the inconvenient

[snip]
> While I think this is obscure, closing a DB automatically closes the storage
> it wraps.  My natural inclination is also to close both explicitly, but I
> get ragged on for that -- the `fstorage.close()` isn't necessary.

I read the documentation, but I miss this info

> 
> > ...
> > The strange is that the exception is raised when i try to commit the
> > transaction in the second call of CreateDatabase
> 
> You confused the transaction machinery, that's all <wink>.

probably :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20051109/ec3f00f5/attachment.bin


More information about the ZODB-Dev mailing list