Commit ebc1dde4 authored by Fabien Morin's avatar Fabien Morin

readd the script move in r26299. In this way, it overload the one of erp5_core

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26324 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fd921e0a
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
This script is used in listbox allowing when switching \'table\' --> \'search\' mode.\n
It will try to generate parts of the document\'s text \n
containing searched words as well highlighting the searched \n
words in the text itself.\n
"""\n
is_gadget_mode = context.REQUEST.get(\'is_gadget_mode\', 0)\n
\n
if is_gadget_mode:\n
# in gadget mode less space is available thus show less text\n
max_text_length = 100\n
max_lines = 1\n
\n
def getRandomDocumentTextExcerpt():\n
# try to get somewhat arbitrary choice of searchable attrs\n
if isinstance(document_text, str) and document_text!=\'\':\n
start = min(len(document_text) - 300, 200)\n
return \'... %s ...\' %document_text[start:start + max_text_length]\n
\n
# get search words from listbox selection\n
argument_names = (\'advanced_search_text\', \n
\'title\',\n
\'reference\',\n
\'searchabletext\', \n
\'searchabletext_any\',\n
\'searchabletext_all\', \n
\'searchabletext_phrase\',)\n
\n
if document_text is None:\n
# convert object to text (if possible)\n
if getattr(context, \'asText\', None) is not None and \\\n
getattr(context, \'hasBaseData\', None) is not None:\n
if context.hasBaseData():\n
# document is successfully converted\n
document_text = context.asText()\n
else:\n
# document not converted (due to a conversion error), return message to user\n
return context.Base_translateString(\'Document is not converted or missing content.\')\n
\n
\n
if selection is not None:\n
params = selection.getParams()\n
else:\n
params = context.portal_selections.getSelectionParamsFor(\'web_search_result_selection\')\n
\n
params = [params.get(name, \'\') for name in argument_names]\n
params = [(hasattr(par, \'sort\') and \'\'.join(par) or par) for par in params]\n
search_string = \' \'.join(params)\n
\n
if search_string.strip() == \'\':\n
# listbox uses its own method, not searching\n
return getRandomDocumentTextExcerpt()\n
\n
search_argument_list = context.Base_parseSearchString(search_string)\n
search_words = search_argument_list.get(\'searchabletext\', None)\n
\n
if search_words in (\'\', None,):\n
# the searched words are empty (e.g. because we used only parameters \n
# without pure searchable text)\n
return getRandomDocumentTextExcerpt()\n
\n
# get fragments of text containing searched words\n
found_text_fragments = context.Base_getExcerptText(\n
context, \\\n
document_text, \\\n
search_words, \\\n
tags = (\'<div style="font-weight:bold;display:inline;">\', \'</div>\'), \\\n
trail = 5, \\\n
maxlines = max_lines)\n
result = \' \'.join(map(str, found_text_fragments))\n
\n
# Document may contains charactors which utf8 codec cannot decode.\n
unicode_result = result.decode(\'utf-8\', \'ignore\')\n
result = unicode_result.encode(\'utf-8\')\n
\n
return result\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>document_text=None, selection=None, max_lines = 5, max_text_length = 500</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>document_text</string>
<string>selection</string>
<string>max_lines</string>
<string>max_text_length</string>
<string>_getattr_</string>
<string>context</string>
<string>is_gadget_mode</string>
<string>getRandomDocumentTextExcerpt</string>
<string>argument_names</string>
<string>None</string>
<string>getattr</string>
<string>params</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>name</string>
<string>par</string>
<string>hasattr</string>
<string>search_string</string>
<string>search_argument_list</string>
<string>search_words</string>
<string>found_text_fragments</string>
<string>map</string>
<string>str</string>
<string>result</string>
<string>unicode_result</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<int>5</int>
<int>500</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_showFoundText</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
967
\ No newline at end of file
968
\ 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