Well, the my_service.get_people() most likely uses a query to retrieve those
people from the database, right? That query would have the effect of putting
those results into the session as persistent objects. When you call
session.save() on one of those already-persisted objects, the session checks
to see if that object is already being tracked. It is, because it was just
loaded from the database as a persistent object.  So,....that triggers the
error.

If you know for sure that the person object was loaded from a query, then
there's no need to .save() the object at all: it's already being tracked.

However, there is no harm in using session.save_or_update(), as that would
check to see if the object was already persisted, find that it was, and then
do nothing anyway.

--~--~---------~--~----~------------~-------~--~----~
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