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
|