A few of my user run into this exception when they use a dialog to
create a new wine purchase.
**** Fri Aug 05 10:24:56 2011 **** Version: 3.2.182.9 ****
wxV: 2.8.11.0 (msw-unicode) *****
Traceback (most recent call last):
File "dialognewwine.pyo", line 779, in OnSaveButton
File "dialognewwine.pyo", line 797, in SaveData
File "sqlalchemy\orm\session.pyo", line 901, in refresh
File "sqlalchemy\orm\session.pyo", line 970, in _expire_state
File "sqlalchemy\orm\session.pyo", line 1261, in _validate_persistent
InvalidRequestError: Instance '<Purchase at 0xc1c7a30>' is not
persistent within this Session
I can't figure out what I am doing wrong which very very rarely causes
this exception, I actually could never recreate it yet, nor one of my
testers, but I had reports from two different users.
Line 797 is the "refresh" line in the following code snippet which is
done when saving the purchase:
# commit it all
self.Getds().commit()
self.Getds().refresh(self.dbItemPurchase)
currencyDBItem = self.dbItemPurchase.currency
I am creating the session like this using SA 0.6.7:
self.engine = db.sa.create_engine(dburl, encoding='utf8',
echo=False)
self.engine.connect() # for a connection now
self.Session = db.sao.sessionmaker()
self.Session.configure(bind=self.engine)
self.ds = self.Session()
The self.dbItemPurchase I create during the startup of the dialog, as
shown below.
self.dbItem = db.Cellarbook()
self.Getds().add(self.dbItem)
self.dbItemVintage = db.Cbvintage()
self.dbItemVintage.cellarbook = self.dbItem
self.dbItem.cbvintage.append(self.dbItemVintage)
self.Getds().add(self.dbItemVintage)
self.dbItemVintageW = db.Wineinfo()
self.dbItemVintage.wineinfo = self.dbItemVintageW
self.Getds().add(self.dbItemVintageW)
self.dbItemBottle = db.Cbbottle()
self.dbItemBottle.cbvintage = self.dbItemVintage
self.dbItemVintage.cbbottle.append(self.dbItemBottle)
self.Getds().add(self.dbItemBottle)
self.dbItemPurchase = db.Purchase()
self.dbItemPurchase.quantity = 1 # dummy
self.dbItemPurchase.cbbottle = self.dbItemBottle
self.dbItemBottle.purchase.append(self.dbItemPurchase)
self.Getds().add(self.dbItemPurchase)
self.Getds().flush()
Anyone can give me some pointers of what I could possibly do wrong which
would cause the instance not being persistent.
Many thanks in advance as I am hitting my head on trying to recreate
this problem for some time now.
Werner
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.