Commit ad0595d3 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

Also, we don't need to look for `transactionless` connection-id here, as we don't use them in
catalog methods.

And, update the files where we can use the new function.
parent c176ff4a
...@@ -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"
......
...@@ -2820,6 +2820,18 @@ class Catalog(Folder, ...@@ -2820,6 +2820,18 @@ 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 == 'Z SQL Method':
if 'deferred' in method.connection_id != deferred:
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