summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2012-05-04 11:36:54 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2012-05-04 12:36:29 (GMT)
commit818be345791c512c2eb5da3073421755e4b49b71 (patch)
tree702c8abb5e3665d78beed67a543fd1cedd3f1e45
parent26844104522632152e99d64cd7bbef92e38dbc79 (diff)
downloadtabellio.pcfdb-818be345791c512c2eb5da3073421755e4b49b71.zip
tabellio.pcfdb-818be345791c512c2eb5da3073421755e4b49b71.tar.gz
tabellio.pcfdb-818be345791c512c2eb5da3073421755e4b49b71.tar.bz2
added synchronisation of object deletions (#1229)
-rw-r--r--tabellio/pcfdb/sync.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index e71f5a9..3741905 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -328,7 +328,8 @@ class SyncFromPcfDbView(BrowserView):
log.info('sync: start [%r] [%r]' % (timestamp, objects))
report = []
for object in ('polgroups', 'sessions', 'deputies', 'ministries', 'persons', 'commissions',
- 'documents', 'dossiers', 'questions', 'reunions', 'deptables', 'thesaurus'):
+ 'documents', 'dossiers', 'questions', 'reunions', 'deptables', 'thesaurus',
+ 'deleted'):
if not 'all' in objects:
if not object in objects:
continue
@@ -1542,3 +1543,38 @@ class SyncFromPcfDbView(BrowserView):
cursor.close()
return 'OK'
+ def sync_deleted(self, timestamp=None):
+ if timestamp is not None:
+ return 'PASS'
+
+ cursor = self.db_connection.cursor()
+
+ cursor.execute('''SELECT t_document.id FROM t_document''')
+ folder_object_ids = set(self.documents_folder.objectIds())
+ database_object_ids = set([str(x[0]) for x in cursor.fetchall()])
+ log.debug('removing documents: %r', folder_object_ids-database_object_ids)
+ self.documents_folder.manage_delObjects(list(folder_object_ids-database_object_ids))
+
+ cursor.execute('''SELECT t_histo.id FROM t_histo
+ WHERE t_histo.type NOT IN ('QA', 'QE', 'QO', 'INTERP')''')
+ folder_object_ids = set(self.dossiers_folder.objectIds())
+ database_object_ids = set([str(x[0]) for x in cursor.fetchall()])
+ log.debug('removing dossiers: %r', folder_object_ids-database_object_ids)
+ self.dossiers_folder.manage_delObjects(list(folder_object_ids-database_object_ids))
+
+ cursor.execute('''SELECT t_histo.id FROM t_histo
+ WHERE t_histo.type IN ('QA', 'QE', 'QO', 'INTERP')''')
+ folder_object_ids = set(self.questions_folder.objectIds())
+ database_object_ids = set([str(x[0]) for x in cursor.fetchall()])
+ log.debug('removing questions: %r', folder_object_ids-database_object_ids)
+ self.questions_folder.manage_delObjects(list(folder_object_ids-database_object_ids))
+
+ cursor.execute('''SELECT id FROM t_reunion''')
+ folder_object_ids = set(self.parlevents_folder.objectIds())
+ database_object_ids = set([str(x[0]) for x in cursor.fetchall()])
+ log.debug('removing reunions: %r', folder_object_ids-database_object_ids)
+ self.parlevents_folder.manage_delObjects(list(folder_object_ids-database_object_ids))
+
+ cursor.close()
+
+ return 'DONE'