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):
if sql_catalog_id is not None:
# try to get connection used in the catalog
catalog = portal.portal_catalog[sql_catalog_id]
for method in catalog.objectValues():
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
connection_id = catalog.getConnectionId()
default_inventory_calculation_list = ({ "inventory_params" : {"section": self.getDestinationSection(),
"node" : self.getDestination(),
......
......@@ -126,16 +126,9 @@ class ArchiveTool(BaseTool):
# Guess connection id from current catalog
source_catalog = portal_catalog.getSQLCatalog()
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():
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
source_connection_id = source_catalog.getConnectionId()
source_deferred_connection_id = source_catalog.getConnectionId(deferred=True)
if source_connection_id is None or source_deferred_connection_id is None:
raise ValueError, "Unable to determine connection id for the current catalog"
......
......@@ -2813,6 +2813,26 @@ class Catalog(Folder,
return filter_dict
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')
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