From dbb01d93a67bf3a8cb470e9ccb95f3f139651478 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 15 Sep 2010 14:16:41 +0200 Subject: [PATCH] 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 --- PLC/Persons.py | 3 ++- PLC/Table.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PLC/Persons.py b/PLC/Persons.py index f4346cec..7917306d 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 b811c627..3380ab5b 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() -- 2.47.0