autoCommit=False and Transaction -> SQLObjectNotFound on creation

Gregor Horvath <[email protected]> Mon, 5 Jan 2015 12:19:20 +0100
Newsgroups gmane.comp.python.sqlobject
Organization Gregor Horvath - Industrieberatung & Softwareentwicklung
Message-ID <20150105121920.4fa85030@florenz>
Hello,

Problem: 

$ dropdb scratch; createdb scratch; python /tmp/scratch.py 
Traceback (most recent call last):
  File "/tmp/scratch.py", line 25, in <module>
    er = Eingangsrechnung(name="test")
  File
 "/home/gregor/work/gnucash/testve/local/lib/python2.7/site-packages/sqlobject/main.py",
line 1226, in __init__
    self._create(id, **kw)
  File
 "/home/gregor/work/gnucash/testve/local/lib/python2.7/site-packages/sqlobject/main.py",
line 1274, in _create
    self._SO_finishCreate(id)
  File
 "/home/gregor/work/gnucash/testve/local/lib/python2.7/site-packages/sqlobject/main.py",
line 1301, in _SO_finishCreate
    self._init(id)
  File
 "/home/gregor/work/gnucash/testve/local/lib/python2.7/site-packages/sqlobject/main.py",
line 934, in _init
    raise SQLObjectNotFound, "The object %s by the ID %s does not
 exist" % (self.__class__.__name__, self.id)
sqlobject.main.SQLObjectNotFound: The object Eingangsrechnung by the ID
1 does not exist

--------------------

$ cat /tmp/scratch.py 
from sqlobject import SQLObject, sqlhub, connectionForURI, ForeignKey,
StringCol

sqlhub.processConnection =
connectionForURI('postgres://gregor@localhost/scratch?debug=0&autoCommit=1')

class Person(SQLObject):
     name = StringCol()

class Eingangsrechnung(SQLObject):
     name = StringCol()

class Buchung(SQLObject): 
     eingangsrechnung = ForeignKey('Eingangsrechnung')
     person = ForeignKey('Person')


Person.createTable()
Eingangsrechnung.createTable()
Buchung.createTable()

sqlhub.processConnection.autoCommit = False
t = Person._connection.transaction()
er = Eingangsrechnung(name="test")
pr = Person(name="test")
Buchung(person=pr, eingangsrechnung=er)
t.commit()

----

It works if I remove the transaction lines, or set autoCommit =True. 
I have tested this with SQLObject 0.12.4 and 2.0.0, same behaviour.
Is this a bug, or do I do something wrong?

--
Greg

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlSqczgACgkQdnTsZ6iRK1VZywCcD9b3BglpysoPc4zevOGaVe7L
tdcAn3TYvYGIVkfIYb9CrFk88bT7n4ZE
=mWmx
-----END PGP SIGNATURE-----