[sqlalchemy] migrating to 0.4: session handling

2007-12-28 Thread Max Ischenko
Hello, I am porting my code to SA 0.4 and cannot figure out whether or not I should work correctly. I have most of my db-related code united under a single DatabaseFacade class which is then bound to SA session via property: class DatabaseFacade(object): ... session =

[sqlalchemy] Re: migrating to 0.4: session handling

2007-12-28 Thread Max Ischenko
On 28 дек, 11:20, Max Ischenko [EMAIL PROTECTED] wrote: Another error I am now getting is: InvalidRequestError: Instance '[EMAIL PROTECTED]' is with key (class ' doupy.model.objects.Invoice', (73L,), None) already persisted with a different identity Any ideas how to fix this? Method

[sqlalchemy] Re: filter_by() related table columns

2007-12-28 Thread Michael Bayer
On Dec 28, 2007, at 9:01 AM, [EMAIL PROTECTED] wrote: theres a certain magical behavior in 0.3 which we've removed in filter_by(), which is that when you say description it searches downwards through orderstatus to find it. 0.4 wants you to be explicit and say session .query

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-28 Thread Michael Bayer
On Dec 28, 2007, at 5:50 AM, Denis S. Otkidach wrote: Sure, I can get an object from DB and copy data from new one. But there is a lot of object types, so have to invent yet another meta description for it (while it already exists in sqlalchemy). And requirements changes often, so I have to

[sqlalchemy] Re: filter_by() related table columns

2007-12-28 Thread [EMAIL PROTECTED]
theres a certain magical behavior in 0.3 which we've removed in filter_by(), which is that when you say description it searches downwards through orderstatus to find it. 0.4 wants you to be explicit and say session .query (PurchaseOrder

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-28 Thread Denis S. Otkidach
On Dec 28, 2007 1:00 AM, Rick Morrison [EMAIL PROTECTED] wrote: Here's the idiom that should work: def ensure_object(sess, id): o = sess.Query(ModelObject).get(id)# if found, o is now loaded into session if not o: o = ModelObject(1, u'title') sess.save(o)

[sqlalchemy] Fancy transaction questions

2007-12-28 Thread Glypho Phobet
I'm using SQLAlchemy 0.4 inside a Pylons application with a SQLite backend. I'm having trouble getting SQLAlchemy transactions to behave how I want. Here's what I want to do, in pseudo-code: begin transaction create new row1 in table1 save row1 do some other (non-database) stuff if

[sqlalchemy] Re: Fancy transaction questions

2007-12-28 Thread Michael Bayer
Im assuming you're writing an ORM centric application for my answers below. If not, the answers would be slightly different. On Dec 28, 2007, at 8:02 PM, Glypho Phobet wrote: Problem #1: I can't get the id of row1 until I commit the transaction. I'd like to be able to get, before I