Commit a97a2903 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Kazuhiko Shiozaki

WIP getCatalogEngine

parent 77ed8ea8
...@@ -894,6 +894,9 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -894,6 +894,9 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
strict_string = 'strict_' strict_string = 'strict_'
related_string = 'related_' related_string = 'related_'
column_map = self.getSQLCatalog(sql_catalog_id).getColumnMap() column_map = self.getSQLCatalog(sql_catalog_id).getColumnMap()
#if key_list == ["destination_title"]:
# import ipdb
# ipdb.set_trace()
for key in key_list: for key in key_list:
prefix = '' prefix = ''
strict = 0 strict = 0
......
...@@ -266,6 +266,8 @@ class DB(TM): ...@@ -266,6 +266,8 @@ class DB(TM):
def columns(self, table_name): def columns(self, table_name):
"""Returns a list of column descriptions for 'table_name'.""" """Returns a list of column descriptions for 'table_name'."""
import ipdb
ipdb.set_trace()
try: try:
c = self._query('SHOW COLUMNS FROM %s' % table_name) c = self._query('SHOW COLUMNS FROM %s' % table_name)
except Exception: except Exception:
......
...@@ -92,6 +92,8 @@ except ImportError: ...@@ -92,6 +92,8 @@ except ImportError:
def getTransactionalVariable(): def getTransactionalVariable():
return {} return {}
show_table_engine_re = re.compile(r'^\)\sENGINE=(\S+)', re.MULTILINE)
def getInstanceID(instance): def getInstanceID(instance):
# XXX: getPhysicalPath is overkill for a unique cache identifier. # XXX: getPhysicalPath is overkill for a unique cache identifier.
# What I would like to use instead of it is: # What I would like to use instead of it is:
...@@ -484,11 +486,6 @@ class Catalog(Folder, ...@@ -484,11 +486,6 @@ class Catalog(Folder,
'type' : 'selection', 'type' : 'selection',
'select_variable' : 'getCatalogMethodIds', 'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' }, 'mode' : 'w' },
{ 'id' : 'sql_catalog_table_description',
'description' : 'Method to get the main catalog table creation description',
'type' : 'selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_catalog_schema', { 'id' : 'sql_catalog_schema',
'description' : 'Method to get the main catalog schema', 'description' : 'Method to get the main catalog schema',
'type' : 'selection', 'type' : 'selection',
...@@ -1064,6 +1061,8 @@ class Catalog(Folder, ...@@ -1064,6 +1061,8 @@ 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):
#import ipdb
#ipdb.set_trace()
result_list = [] result_list = []
try: try:
method_name = self.sql_catalog_schema method_name = self.sql_catalog_schema
...@@ -1078,6 +1077,22 @@ class Catalog(Folder, ...@@ -1078,6 +1077,22 @@ class Catalog(Folder,
pass pass
return tuple(result_list) return tuple(result_list)
def _getSQLCatalogEngine(self, table=None):
"""
"""
result = ""
try:
method_name = self.sql_catalog_table_description
method = getattr(self, method_name)
search_result = method(table=table)
result = show_table_engine_re.search(getattr(search_result[0], "CREATE TABLE")).group(1)
except ConflictError:
raise
except:
LOG('SQLCatalog', WARNING, '_getCatalogEngine failed with the method %s' % method_name, error=sys.exc_info())
pass
return result
@caching_instance_method(id='SQLCatalog.getColumnIds', @caching_instance_method(id='SQLCatalog.getColumnIds',
cache_factory='erp5_content_long', cache_factory='erp5_content_long',
cache_id_generator=generateCatalogCacheId, cache_id_generator=generateCatalogCacheId,
...@@ -1099,6 +1114,8 @@ class Catalog(Folder, ...@@ -1099,6 +1114,8 @@ class Catalog(Folder,
return sorted(keys) return sorted(keys)
def getColumnIds(self): def getColumnIds(self):
#import ipdb
#ipdb.set_trace()
""" """
Calls the show column method and returns dictionnary of Calls the show column method and returns dictionnary of
Field Ids Field Ids
...@@ -2436,6 +2453,8 @@ class Catalog(Folder, ...@@ -2436,6 +2453,8 @@ class Catalog(Folder,
if column in result: if column in result:
LOG('SQLCatalog', WARNING, 'Ambiguous configuration: column %r is set to use %r key, but also to use %r key. Former takes precedence.' % (column, result[column], key)) LOG('SQLCatalog', WARNING, 'Ambiguous configuration: column %r is set to use %r key, but also to use %r key. Former takes precedence.' % (column, result[column], key))
else: else:
# if column in ("title", "description") and key == "FullTextKey":
# if mroonga: key = "MroongaFullTextKey"
result[column] = key result[column] = key
for line in self.sql_catalog_search_keys: for line in self.sql_catalog_search_keys:
try: try:
......
...@@ -93,6 +93,7 @@ class FullTextKey(SearchKey): ...@@ -93,6 +93,7 @@ class FullTextKey(SearchKey):
append(SimpleQuery(search_key=self, append(SimpleQuery(search_key=self,
comparison_operator=comparison_operator, comparison_operator=comparison_operator,
group=group, **{column: ' '.join(value_list)})) group=group, **{column: ' '.join(value_list)}))
#raise RuntimeError("XXX Tristan FullTextKey.py 1")
return query_list return query_list
verifyClass(ISearchKey, FullTextKey) verifyClass(ISearchKey, FullTextKey)
......
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