Commit df76fb35 authored by Yusei Tahara's avatar Yusei Tahara

Reduce queries for searching and fix some variable names.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17977 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5bde2bc5
......@@ -3,8 +3,11 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
......@@ -73,27 +76,29 @@ and make sure we get latest/most relevant version\n
should be reimplemented in SQL some sunny day.\n
"""\n
\n
ss = []\n
search_term_list = []\n
\n
if context.getReference() is None: \n
return []\n
\n
ss.append(context.getReference())\n
search_term_list.append(context.getReference())\n
\n
if context.getLanguage() is not None:\n
ss.append(context.getReference() + \'-\' + context.getLanguage())\n
search_term_list.append(context.getReference() + \'-\' + context.getLanguage())\n
if context.getVersion() is not None:\n
ss.append(context.getReference() + \'-\' + context.getLanguage() + \'-\' + context.getVersion())\n
search_term_list.append(context.getReference() + \'-\' + context.getLanguage() + \'-\' + context.getVersion())\n
\n
# Find from only document types\n
document_type_list = context.getPortalDocumentTypeList()\n
\n
lst=[]\n
for t in ss:\n
kw = {\'full_text.SearchableText\':\'%\' + t + \'%\'}\n
lst += context.portal_catalog(portal_type=document_type_list, **kw)\n
kw = {}\n
searchable_text_list = []\n
for term in search_term_list:\n
searchable_text_list.append(\'%\'+term+\'%\')\n
kw[\'full_text.SearchableText\'] = searchable_text_list\n
result = context.portal_catalog(portal_type=document_type_list, **kw)\n
\n
return lst\n
return result\n
</string> </value>
</item>
<item>
......@@ -144,16 +149,17 @@ return lst\n
<tuple>
<string>a</string>
<string>kw</string>
<string>ss</string>
<string>search_term_list</string>
<string>_getattr_</string>
<string>context</string>
<string>None</string>
<string>document_type_list</string>
<string>lst</string>
<string>searchable_text_list</string>
<string>_getiter_</string>
<string>t</string>
<string>_inplacevar_</string>
<string>term</string>
<string>_write_</string>
<string>_apply_</string>
<string>result</string>
</tuple>
</value>
</item>
......
727
\ No newline at end of file
728
\ No newline at end of file
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