Having in mind documentation remarks on is_modified for scalar values is

modified = session.is_modified(obj) and obj in session.dirty

a good way to determine if obj was modified?


W dniu środa, 4 listopada 2015 02:03:05 UTC+1 użytkownik Michael Bayer 
napisał:
>
>
>
> On 11/03/2015 03:21 PM, c.b...@posteo.jp <javascript:> wrote: 
> > Is there a way to find out if a persistent sqlalchemy mapped object was 
> > modified? 
> > 
> > It means I recieve a object (persistent, with identiy) from the 
> > database. Then the user (maybe!) modify its data in a dialog-window. 
> > 
> >    obj = session.query(MyClass).first() 
> >    LetTheUserDoSomethingWithIt(obj) 
> >    if obj.is_modified() 
> > 
> > Is there a way to find out if the object in memory/RAM was modified 
> > compared to its instance in the database itself? I don't want to 
> > compare each attribute against the data in the dialog-window. 
>
>
> session.is_modified(obj) will do this for you: 
>
>
>
> http://docs.sqlalchemy.org/en/rel_1_0/orm/session_api.html?highlight=is_modified#sqlalchemy.orm.session.Session.is_modified
>  
>
> read the docs carefully, this method can be tricky. 
>
>
>
>
> > 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to