avoid running validate on DeletePerson
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 15 Sep 2010 12:16:41 +0000 (14:16 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 15 Sep 2010 12:16:41 +0000 (14:16 +0200)
this is for when the db accidentally has duplicates, as we found after
a big RefreshPeer hiccup
cleaning up manually through SQL in similar cases is discouraged

PLC/Persons.py
PLC/Table.py

index f4346ce..7917306 100644 (file)
@@ -362,7 +362,8 @@ class Person(Row):
 
         # Mark as deleted
         self['deleted'] = True
-        self.sync(commit)
+        # don't validate, so duplicates can be consistently removed
+        self.sync(commit, validate=False)
 
 class Persons(Table):
     """
index b811c62..3380ab5 100644 (file)
@@ -315,13 +315,15 @@ class Row(dict):
         y = self.db_fields(y)
         return dict.__eq__(x, y)
 
-    def sync(self, commit = True, insert = None):
+    # validate becomes optional on sept. 2010
+    # we find it useful to use DeletePerson on duplicated entries
+    def sync(self, commit = True, insert = None, validate=True):
         """
         Flush changes back to the database.
         """
 
         # Validate all specified fields
-        self.validate()
+        if validate: self.validate()
 
         # Filter out fields that cannot be set or updated directly
         db_fields = self.db_fields()