Looks like you're going to want to do something a bit different:
http://www.sqlalchemy.org/docs/05/reference/orm/interfaces.html#sqlalchemy.orm.interfaces.MapperExtensiondiscusses
how to do actions after updates/etc are performed.

On Sun, Jul 18, 2010 at 7:31 PM, Diez B. Roggisch <[email protected]> wrote:

>
> Am 19.07.2010 um 00:40 schrieb Timuçin Kızılay:
>
>
>  ok, here is what I do for record updates...
>>
>>
>> -----------------------
>> rec = model.DBSession.query(model.Sometable).filter_by(id=id).one()
>>
>> rec.a = 'some new text'
>>
>> model.DBSession.flush()
>> ---------------------
>>
>> I can add a property to the model object but I do now know how to filter
>> by a property.
>>
>> here is model object with property added:
>> ----------------------------
>> class Sometable(DeclarativeBase):
>>    __tablename__ = 'sometable'
>>    id = Column(Integer, autoincrement=True, primary_key=True)
>>    a = Column(Unicode(50))
>>    b = Column(Unicode(50))
>>
>>    @property
>>    def c(self):
>>         return self.a + self.b
>> ----------------------
>>
>> this works but I need to make queries like this :
>>
>> q =
>> model.DBSession.query(model.Sometable).filter(model.Sometable.c.like('something'))
>>
>>
>> That's why I need to have another field.
>>
>>
> You should be able to concatenate the fields + then operate on that with
> like.
>
> Like (untested)
>
>   = model.DBSession.query(model.Sometable).filter((model.Sometable.a |
>> model.Sometable.b).like('something'))
>>
>
> As the SA-ML about this, with the operator your DB uses for concatenation.
> OR maybe there is a function.
>
> Diez
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<turbogears%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
>
>


-- 
Michael J. Pedersen
My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171
          Yahoo/pedermj2002, MSN/[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to