Commit 6e7e12e0 authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Ayush Tiwari

Products.ZSQLCatalog.SQLcatalog: Add function to get normal or deferred connection id for catalog

And, change in files where this was being used
parent 79119142
...@@ -115,12 +115,7 @@ class Inventory(Delivery): ...@@ -115,12 +115,7 @@ class Inventory(Delivery):
if sql_catalog_id is not None: if sql_catalog_id is not None:
# try to get connection used in the catalog # try to get connection used in the catalog
catalog = portal.portal_catalog[sql_catalog_id] catalog = portal.portal_catalog[sql_catalog_id]
for method in catalog.objectValues(): connection_id = catalog.getConnectionId()
if method.meta_type == "Z SQL Method":
if 'deferred' not in method.connection_id \
and 'transactionless' not in method.connection_id:
connection_id = method.connection_id
break
default_inventory_calculation_list = ({ "inventory_params" : {"section": self.getDestinationSection(), default_inventory_calculation_list = ({ "inventory_params" : {"section": self.getDestinationSection(),
"node" : self.getDestination(), "node" : self.getDestination(),
......
...@@ -126,16 +126,9 @@ class ArchiveTool(BaseTool): ...@@ -126,16 +126,9 @@ class ArchiveTool(BaseTool):
# Guess connection id from current catalog # Guess connection id from current catalog
source_catalog = portal_catalog.getSQLCatalog() source_catalog = portal_catalog.getSQLCatalog()
source_catalog_id = source_catalog.getId() source_catalog_id = source_catalog.getId()
if source_connection_id is None or source_deferred_connection_id is None:
for method in source_catalog.objectValues(): source_connection_id = source_catalog.getConnectionId()
if method.meta_type == "Z SQL Method": source_deferred_connection_id = source_catalog.getConnectionId(deferred=True)
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: if source_connection_id is None or source_deferred_connection_id is None:
raise ValueError, "Unable to determine connection id for the current catalog" raise ValueError, "Unable to determine connection id for the current catalog"
......
...@@ -2813,6 +2813,26 @@ class Catalog(Folder, ...@@ -2813,6 +2813,26 @@ class Catalog(Folder,
return filter_dict return filter_dict
return None return None
security.declarePublic('getConnectionId')
def getConnectionId(self, deferred=False):
"""
Returns the 'normal' connection being used by the SQL Method(s) in this
catalog.
If 'deferred' is True, then returns the deferred connection
"""
for method in self.objectValues():
if method.meta_type in ['Z SQL Method',]:
if deferred:
if 'deferred' in method.connection_id:
return method.connection_id
else:
continue
else:
if 'deferred' in method.connection_id:
continue
else:
return method.connection_id
security.declarePrivate('getFilterableMethodList') security.declarePrivate('getFilterableMethodList')
def getFilterableMethodList(self): def getFilterableMethodList(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment