Re: [sqlalchemy] session lifecycle and wsgi

2010-04-29 Thread Chris Withers
Michael Bayer wrote: if your application keeps a handle on objects after the request is complete, and then passed them somewhere else, like a background thread or something, then the subsequent request is going to be potentially touching those objects at the same time. This would all be pretty

[sqlalchemy] Re: Select.compare()

2010-04-29 Thread dimazest
Thank you for the reply, I was thinking to use something similar. On Apr 28, 11:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: dimazest wrote: Hi all, I faced a problem comparing Selects. It seems that Select.compare() works incorrectly. Here is the code that shows the problem:

[sqlalchemy] Re: session lifecycle and wsgi

2010-04-29 Thread Laurence Rowe
On Apr 28, 4:38 pm, Chris Withers ch...@simplistix.co.uk wrote: Laurence Rowe wrote: Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. It doesn't do the .remove(). BFG currently has a

[sqlalchemy] making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
Before saving objects to the database, we have need to inspect the changes. I am aware of the attributes.get_history() functionality, which is helpful to a point. attributes.get_history() falls short of what I need in two places: *** after a session.flush(), it is gone. There are times we need

Re: [sqlalchemy] Re: session lifecycle and wsgi

2010-04-29 Thread Chris Withers
Laurence Rowe wrote: On Apr 28, 4:38 pm, Chris Withers ch...@simplistix.co.uk wrote: Laurence Rowe wrote: Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. It doesn't do the .remove(). BFG

Re: [sqlalchemy] Mapper can't map primary key

2010-04-29 Thread Lance Edgar
On 4/28/2010 11:31 PM, Mark wrote: Hi guys, I have the following Table construction: ADMIN_TABLE = Table('admin', bound_meta_data, Column('username', types.VARCHAR(100), primary_key=True), autoload=True,

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-29 Thread Michael Bayer
Chris Withers wrote: Michael Bayer wrote: we have the in_() construct. It should be in the ORM and SQL expression tutorials: t1 = Table('mytable', metadata, Column('foo', String)) select([t1]).where(t1.c.foo.in_(['a', 'b', 'c'])) However, that requires table/column objects which I don't

Re: [sqlalchemy] Mapper can't map primary key

2010-04-29 Thread Michael Bayer
Mark wrote: sqlalchemy.exc.ArgumentError: Mapper Mapper|Admin|admin could not assemble any primary key columns for mapped table 'admin' As you can see above, I have already mapped the primary_key=True property, why is it still complaining that it can't find the primary key? With this error,

Re: [sqlalchemy] making a transient copy of instances recursively at merge() time

2010-04-29 Thread Michael Bayer
Kent wrote: Before saving objects to the database, we have need to inspect the changes. I am aware of the attributes.get_history() functionality, which is helpful to a point. attributes.get_history() falls short of what I need in two places: *** after a session.flush(), it is gone. There

[sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
That sounds like it could be very useful for me, thank you for pointing me there. That could solve one of the two issues I'm facing that I listed... what about the other? On Apr 29, 11:02 am, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Before saving objects to the database, we

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Michael Bayer
if you have a method like 'calculate_total_volume()', that is a business method. you should not be relying upon the internals of the ORM to figure that out for you, and you should have two distinct fields on your object to represent the two values you need to make that calculation. Kent wrote:

[sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
There might be a communication problem, which an example could help clarify. I'm constrained by a legacy database that I have no control over changing. When an order is changed, I need to calculate the change in volume (or points) so I can update a table that records this information. Here is

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Michael Bayer
Kent wrote: There might be a communication problem, which an example could help clarify. I'm constrained by a legacy database that I have no control over changing. When an order is changed, I need to calculate the change in volume (or points) so I can update a table that records this

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Michael Bayer
Michael Bayer wrote: Kent wrote: There might be a communication problem, which an example could help clarify. I'm constrained by a legacy database that I have no control over changing. When an order is changed, I need to calculate the change in volume (or points) so I can update a table

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent Bower
I'm exactly trying to avoid adding esoteric hacks - (why I posted in the first place), so thanks for the information. I'll look into the examples you've provided; I'm hopeful that the versioned objects have in-tact relations (such that I could say old_object.orderdetails and get that

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent Bower
It is helpful to know what SQLA was designed for. Also, you may be interested to know of our project as we are apparently stretching SQLA's use case/design. We are implementing a RESTful web app (using TurboGears) on an already existent legacy database. Since our webservice calls (and

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Michael Bayer
Kent Bower wrote: It is helpful to know what SQLA was designed for. Also, you may be interested to know of our project as we are apparently stretching SQLA's use case/design. We are implementing a RESTful web app (using TurboGears) on an already existent legacy database. Since our