From: Thierry Parmentelat Date: Wed, 15 Sep 2010 12:16:41 +0000 (+0200) Subject: avoid running validate on DeletePerson X-Git-Tag: plcapi-5.0-17~3 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=dbb01d93a67bf3a8cb470e9ccb95f3f139651478 avoid running validate on DeletePerson 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 --- diff --git a/PLC/Persons.py b/PLC/Persons.py index f4346ce..7917306 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -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): """ diff --git a/PLC/Table.py b/PLC/Table.py index b811c62..3380ab5 100644 --- a/PLC/Table.py +++ b/PLC/Table.py @@ -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()