[sqlalchemy] How can I know the state of an instances?

2008-12-27 Thread Chen Houwu
I want to do as following: if instance is Transient: do something else instance is Pending: do something else How can I accomplish it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: Updating existing objects

2008-12-27 Thread Eric Abrahamsen
On Dec 27, 2008, at 1:39 PM, Andreas Jung wrote: On 27.12.2008 3:06 Uhr, Eric Abrahamsen wrote: Sorry for the very beginner question, but I haven't been able to find a good discussion of this issue online (possibly because it's too basic). I'm using sqlalchemy as part of a basic web-based

[sqlalchemy] Callback on save when value of field has changed?

2008-12-27 Thread Jim Jones
Hi List, I have this simple model (in declarative style): class Item( Base ): __tablename__ = 'items' desc = Column( 'desc', UnicodeText(), nullable=False ) email = Column( 'email', UnicodeText(), nullable=False ) How can I trigger an event when the value of 'desc' has changed and

[sqlalchemy] Re: Callback on save when value of field has changed?

2008-12-27 Thread Andreas Jung
On 27.12.2008 11:06 Uhr, Jim Jones wrote: Hi List, I have this simple model (in declarative style): class Item( Base ): __tablename__ = 'items' desc = Column( 'desc', UnicodeText(), nullable=False ) email = Column( 'email', UnicodeText(), nullable=False ) How can I

[sqlalchemy] Re: Callback on save when value of field has changed?

2008-12-27 Thread Jim Jones
Andreas Jung wrote: On 27.12.2008 11:06 Uhr, Jim Jones wrote: Hi List, I have this simple model (in declarative style): class Item( Base ): __tablename__ = 'items' desc = Column( 'desc', UnicodeText(), nullable=False ) email = Column( 'email', UnicodeText(),

[sqlalchemy] Re: How can I know the state of an instances?

2008-12-27 Thread Michael Bayer
if instance in session: do something else: do something else alternatively, you can explicitly say elif instance in session.new: On Dec 27, 2008, at 4:35 AM, Chen Houwu wrote: I want to do as following: if instance is Transient: do something else instance is Pending:

[sqlalchemy] Subqueries as secondary tables

2008-12-27 Thread Alan Shields
(wow, way to go tab key! Sorry, folks) I'm having a bit of trouble and I think it may be a deficiency in my understanding of SqlAlchemy. Let's say I have: Table(Apples) Table(Crates) apples_by_crate = \ select([ crate_table.c.id.label(crate_id),