Seems that things break when you use __dict__.... So don't use it.

Use a getattr and a setattr. If you really want, you can implement
getitem and setitem that just wrap setattr and getattr on your model.


Why doesn't sqlalchemy basemodel do this already? Everything in python
is a dictionary, seems natural to provide dict access as an
alternative by default.

--
Thadeus





On Fri, Sep 3, 2010 at 9:08 PM, Thadeus Burgess <[email protected]> wrote:
> If I have a record object.
>
> me = Person.query.get(id)
>
> and I access me.__dict__ everything looks good.
>
> However when I execute a db.session.commit()
>
> the me.__dict__ disappears and only contains _sa_state_instance
>
> The second I access an attribute of the me instance, __dict__ comes back.
>
> What is the best way to always make sure the __dict__ instance is
> always populated with the object data without knowing any of the
> column names ahead of time ?
>
> --
> Thadeus
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to