Commit 7a221299 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

add sql_catalog_search_keys, that makes it possible to customise Column - SearchKey mappings.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37941 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0e8df2b9
This diff is collapsed.
......@@ -130,6 +130,11 @@ class BusinessTemplate:
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_catalog_search_key',
'description' : 'A list of ids of catalog search keys used by this template',
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_catalog_keyword_key',
'description' : 'A list of ids of catalog keyword keys used by this template',
'type' : 'lines',
......
......@@ -2,10 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
......@@ -77,6 +74,7 @@
<string>my_template_catalog_method_id_list</string>
<string>my_template_catalog_result_table_list</string>
<string>my_template_catalog_result_key_list</string>
<string>my_template_catalog_search_key_list</string>
<string>my_template_catalog_keyword_key_list</string>
<string>my_template_catalog_datetime_key_list</string>
<string>my_template_catalog_role_key_list</string>
......
......@@ -1786,6 +1786,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
related_key = 'fake_id | category/catalog/z_fake_method'
result_key = 'catalog.title'
result_table = 'fake_catalog'
search_key = 'fake_search_key | FakeSearchKey'
keyword_key = 'fake_keyword'
full_text_key = 'fake_full_text'
request_key = 'fake_request'
......@@ -1817,6 +1818,13 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sql_search_related_keys.sort()
catalog.sql_catalog_related_keys = tuple(sql_search_related_keys)
self.failUnless(related_key in catalog.sql_catalog_related_keys)
# search keys
if search_key not in catalog.sql_catalog_search_keys:
sql_catalog_search_keys = list(catalog.sql_catalog_search_keys)
sql_catalog_search_keys.append(search_key)
sql_catalog_search_keys.sort()
catalog.sql_catalog_search_keys = tuple(sql_catalog_search_keys)
self.failUnless(search_key in catalog.sql_catalog_search_keys)
# keyword keys
if keyword_key not in catalog.sql_catalog_keyword_search_keys:
sql_catalog_keyword_keys = list(catalog.sql_catalog_keyword_search_keys)
......@@ -1875,7 +1883,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(local_role_key in catalog.sql_catalog_local_role_keys)
sequence.edit(related_key=related_key, result_key=result_key,
result_table=result_table,
result_table=result_table, search_key=search_key,
keyword_key=keyword_key, full_text_key=full_text_key,
request_key=request_key,
multivalue_key=multivalue_key, topic_key=topic_key, \
......@@ -1951,6 +1959,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(result_key is not None)
result_table = sequence.get('result_table', None)
self.failUnless(result_table is not None)
search_key = sequence.get('search_key', None)
self.failUnless(search_key is not None)
keyword_key = sequence.get('keyword_key', None)
self.failUnless(keyword_key is not None)
full_text_key = sequence.get('full_text_key', None)
......@@ -1971,6 +1981,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
bt.edit(template_catalog_related_key_list=[related_key],
template_catalog_result_key_list=[result_key],
template_catalog_result_table_list=[result_table],
template_catalog_search_key_list=[search_key],
template_catalog_keyword_key_list=[keyword_key],
template_catalog_full_text_key_list=[full_text_key],
template_catalog_request_key_list=[request_key],
......@@ -1991,6 +2002,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(result_key is not None)
result_table = sequence.get('result_table', None)
self.failUnless(result_table is not None)
search_key = sequence.get('search_key', None)
self.failUnless(search_key is not None)
keyword_key = sequence.get('keyword_key', None)
self.failUnless(keyword_key is not None)
full_text_key = sequence.get('full_text_key', None)
......@@ -2028,6 +2041,12 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sql_search_tables.sort()
catalog.sql_search_tables = tuple(sql_search_tables)
self.failUnless(result_table not in catalog.sql_search_tables)
# search keys
sql_catalog_search_keys = list(catalog.sql_catalog_search_keys)
sql_catalog_search_keys.remove(search_key)
sql_catalog_search_keys.sort()
catalog.sql_catalog_search_keys = tuple(sql_catalog_search_keys)
self.failUnless(search_key not in catalog.sql_catalog_search_keys)
# keyword keys
sql_catalog_keyword_keys = list(catalog.sql_catalog_keyword_search_keys)
sql_catalog_keyword_keys.remove(keyword_key)
......@@ -2087,6 +2106,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(result_key is not None)
result_table = sequence.get('result_table', None)
self.failUnless(result_table is not None)
search_key = sequence.get('search_key', None)
self.failUnless(search_key is not None)
keyword_key = sequence.get('keyword_key', None)
self.failUnless(keyword_key is not None)
full_text_key = sequence.get('full_text_key', None)
......@@ -2112,6 +2133,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(related_key in catalog.sql_catalog_related_keys)
# result table
self.failUnless(result_table in catalog.sql_search_tables)
# search key
self.failUnless(search_key in catalog.sql_catalog_search_keys)
# keyword key
self.failUnless(keyword_key in catalog.sql_catalog_keyword_search_keys)
# full text key
......@@ -2139,6 +2162,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(result_key is not None)
result_table = sequence.get('result_table', None)
self.failUnless(result_table is not None)
search_key = sequence.get('search_key', None)
self.failUnless(search_key is not None)
keyword_key = sequence.get('keyword_key', None)
self.failUnless(keyword_key is not None)
full_text_key = sequence.get('full_text_key', None)
......@@ -2164,6 +2189,8 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(related_key not in catalog.sql_catalog_related_keys)
# result table
self.failUnless(result_table not in catalog.sql_search_tables)
# search key
self.failUnless(search_key not in catalog.sql_catalog_search_keys)
# keyword key
self.failUnless(keyword_key not in catalog.sql_catalog_keyword_search_keys)
# full text key
......
......@@ -451,6 +451,11 @@ class Catalog(Folder,
'type' : 'selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id': 'sql_catalog_search_keys',
'title': 'Search Key Mappings',
'description': 'A list of Search Key mappings',
'type': 'lines',
'mode': 'w' },
{ 'id' : 'sql_catalog_keyword_search_keys',
'description' : 'Columns which should be considered as full text search',
'type' : 'multiple selection',
......@@ -544,6 +549,7 @@ class Catalog(Folder,
sql_catalog_index = ''
sql_unique_values = ''
sql_catalog_paths = ''
sql_catalog_search_keys = ()
sql_catalog_keyword_search_keys = ()
sql_catalog_datetime_search_keys = ()
sql_catalog_full_text_search_keys = ()
......@@ -2265,6 +2271,12 @@ class Catalog(Folder,
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:
result[column] = key
for line in self.sql_catalog_search_keys:
try:
column, key = [x.strip() for x in line.split('|', 2)]
result[column] = key
except ValueError:
LOG('SQLCatalog', WARNING, 'Wrong configuration for sql_catalog_search_keys: %r' % line)
return result
@profiler_decorator
......
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