so u'd get two objects sharing same dict, and changin one will break the other, in a hideous way. better copy stuff one by one, or invent some other way.
On Wednesday 03 December 2008 22:47:34 [EMAIL PROTECTED] wrote: > I wrote it on usage reciepts, but no one answered yet. > > The reason I'm doing so, is to solve the following problem: I have > an object that is compounded from the fields - obj_id, num1, num2, > num3. obj_id is my primary key. I want to create a save method for > the object's class, that will do the following: > If the object is in the session, save it. > Else, if there is another object in the db with the same num1 and > num2, use the object in the db instead of the current one, and warn > the user if num3 is different. > So it's quite like merge, but not necessarily on the primary key. > Now, I want that "use the object in the db" wouldn't be by > "returning" the object after the merge (original object if didn't > exist, and db_object if existed), but really "replacing" it > (self.dict = > existing_object.dict), so one can use that object afterwards, > without being confused. > > > I know that I can make a constraint in the DB that num1 and num2 > would be unique so that object won't be created (the user will get > an exception), but it won't really be a fix for my problem, because > it's important for my users not to get that kind of exceptions > (Especially because I have another mapped clazz, that is the > contatiner of many "obj", so way they will save that class they > don't won't to deal with the case that one of the "obj" already > existed). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---