Is there an elegant way of replacing all the attributes of an instance, except the primary key ?
Currently, I create a new object with all the date, fetch the old object and do for k,v in new: old.__setattr__(k, v), taking care to skip the primary key attribute. There's a custom __iter__ method for the class to make sure this works. Just setting the primary key attribute (say 'id') as new.id = old.id doesn't do the right thing and fails with an Duplicate key error. To set the context, what I am attempting here is to add an "import" function. The objects are serialised to YAML and I want to replace rather than add in case the object already exists in the DB. Any help appreciated. -- Alok -- 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.
