Commit cf657fc4 authored by Boris Kocherov's avatar Boris Kocherov Committed by Vincent Pelletier

sqlcatalog properties could not be changed through form edit if database connection does not exist.

parent 254a3712
...@@ -28,6 +28,7 @@ from AccessControl.SimpleObjectPolicies import ContainerAssertions ...@@ -28,6 +28,7 @@ from AccessControl.SimpleObjectPolicies import ContainerAssertions
from BTrees.OIBTree import OIBTree from BTrees.OIBTree import OIBTree
from App.config import getConfiguration from App.config import getConfiguration
from BTrees.Length import Length from BTrees.Length import Length
from Shared.DC.ZRDB.DA import DatabaseError
from Shared.DC.ZRDB.TM import TM from Shared.DC.ZRDB.TM import TM
from Acquisition import aq_parent, aq_inner, aq_base from Acquisition import aq_parent, aq_inner, aq_base
...@@ -1076,19 +1077,22 @@ class Catalog(Folder, ...@@ -1076,19 +1077,22 @@ class Catalog(Folder,
return self.sql_search_result_keys return self.sql_search_result_keys
def _getCatalogSchema(self, table=None): def _getCatalogSchema(self, table=None):
result_list = []
try:
method_name = self.sql_catalog_schema method_name = self.sql_catalog_schema
try:
method = getattr(self, method_name) method = getattr(self, method_name)
search_result = method(table=table) except AttributeError:
for c in search_result: pass
result_list.append(c.Field) else:
except ConflictError: try:
return tuple(c.Field for c in method(table=table))
except (ConflictError, DatabaseError):
raise raise
except: except Exception:
LOG('SQLCatalog', WARNING, '_getCatalogSchema failed with the method %s' % method_name, error=sys.exc_info())
pass pass
return tuple(result_list)
LOG('SQLCatalog', WARNING, '_getCatalogSchema failed with the method %s'
% method_name, error=sys.exc_info())
return ()
@transactional_cache_decorator('SQLCatalog.getColumnIds') @transactional_cache_decorator('SQLCatalog.getColumnIds')
def _getColumnIds(self): def _getColumnIds(self):
...@@ -1160,18 +1164,22 @@ class Catalog(Folder, ...@@ -1160,18 +1164,22 @@ class Catalog(Folder,
Calls the show table method and returns dictionnary of Calls the show table method and returns dictionnary of
Field Ids Field Ids
""" """
keys = []
method_name = self.sql_catalog_tables method_name = self.sql_catalog_tables
try: try:
method = getattr(self, method_name) method = getattr(self, method_name)
search_result = method() except AttributeError:
for c in search_result: pass
keys.append(c[0]) else:
except ConflictError: try:
return [c[0] for c in method()]
except (ConflictError, DatabaseError):
raise raise
except: except Exception:
pass pass
return keys
LOG('SQLCatalog', WARNING, 'getTableIds failed with the method %s'
% method_name, error=sys.exc_info())
return []
security.declarePrivate('getUIDBuffer') security.declarePrivate('getUIDBuffer')
def getUIDBuffer(self, force_new_buffer=False): def getUIDBuffer(self, force_new_buffer=False):
......
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