Commit c9470194 authored by Ivan Tyagov's avatar Ivan Tyagov

Check if text exists before trying to get a random excerpt from it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25254 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ab68991e
......@@ -66,6 +66,7 @@ is_gadget_mode = context.REQUEST.get(\'is_gadget_mode\', 0)\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
if is_gadget_mode:\n
# in gadget mode less space is available thus show less text\n
......@@ -83,7 +84,6 @@ argument_names = (\'advanced_search_text\', \n
\n
if document_text is None:\n
# convert object to text (if possible)\n
document_text = \'\'\n
if getattr(context, \'asText\', None) is not None and \\\n
getattr(context, \'hasBaseData\', None) is not None:\n
if context.hasBaseData():\n
......@@ -108,7 +108,7 @@ if search_string.strip() == \'\':\n
return getRandomDocumentTextExcerpt()\n
\n
search_argument_list = context.Base_parseSearchString(search_string)\n
search_words = search_argument_list.get(\'searchabletext\')\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
......
950
\ No newline at end of file
952
\ 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