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