From 07f480ed7f727f02d26904a4d6c9809d3afec678 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Wed, 6 Apr 2011 09:54:23 +0000
Subject: [PATCH] manage_archive can take more argument as the research of
 currently used connection might failed in some cases (no zsql method using a
 deferred connection for example)

This should be replace later using a mapping between connection as parameter



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45126 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Catalog/Tool/ArchiveTool.py | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/product/ERP5Catalog/Tool/ArchiveTool.py b/product/ERP5Catalog/Tool/ArchiveTool.py
index d5b5f0c20e..98882c14d1 100755
--- a/product/ERP5Catalog/Tool/ArchiveTool.py
+++ b/product/ERP5Catalog/Tool/ArchiveTool.py
@@ -103,10 +103,12 @@ class ArchiveTool(BaseTool):
 
   def manage_archive(self, destination_archive_id,
                      archive_id,
+                     source_connection_id=None,
+                     source_deferred_connection_id=None,
                      update_destination_sql_catalog=None,
                      update_archive_sql_catalog=None,
                      clear_destination_sql_catalog=None,
-                     clear_archive_sql_catalog=None,                                            
+                     clear_archive_sql_catalog=None,
                      REQUEST=None, RESPONSE=None):
     """
     This method is used to populate an archive from the current catalog
@@ -124,17 +126,16 @@ class ArchiveTool(BaseTool):
     # Guess connection id from current catalog
     source_catalog = portal_catalog.getSQLCatalog()
     source_catalog_id = source_catalog.getId()
-    source_connection_id = None
-    source_deferred_connection_id = None
-    for method in source_catalog.objectValues():
-      if method.meta_type == "Z SQL Method":
-        if 'deferred' in method.connection_id:
-          source_deferred_connection_id = method.connection_id
-        elif 'transactionless' not in method.connection_id:
-          source_connection_id = method.connection_id
-        if source_connection_id is not None and \
-           source_deferred_connection_id is not None:
-          break
+    if source_connection_id is None or source_deferred_connection_id is None:
+      for method in source_catalog.objectValues():
+        if method.meta_type == "Z SQL Method":
+          if source_deferred_connection_id is None and 'deferred' in method.connection_id:
+            source_deferred_connection_id = method.connection_id
+          elif source_connection_id is None and 'transactionless' not in method.connection_id:
+            source_connection_id = method.connection_id
+          if source_connection_id is not None and \
+             source_deferred_connection_id is not None:
+            break
 
     if source_connection_id is None or source_deferred_connection_id is None:
       raise ValueError, "Unable to determine connection id for the current catalog"
-- 
2.30.9