Commit 49a6627d authored by Bartek Górny's avatar Bartek Górny

do not use all kw for searching (because kw are pulled from selection and become persistent)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12529 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b90c8920
...@@ -89,8 +89,10 @@ TODO: use catalog to get only the user\'s docs - this implementation is slow.\n ...@@ -89,8 +89,10 @@ TODO: use catalog to get only the user\'s docs - this implementation is slow.\n
\n \n
# SearchableText can be supplied in request or stored in selection\n # SearchableText can be supplied in request or stored in selection\n
sstr = context.REQUEST.get(\'SearchableText\')\n sstr = context.REQUEST.get(\'SearchableText\')\n
\n
if not sstr:\n if not sstr:\n
sstr = kw.get(\'SearchableText\')\n sstr = kw.get(\'SearchableText\')\n
\n
if not sstr: return []\n if not sstr: return []\n
\n \n
args = context.parseSearchString(sstr)\n args = context.parseSearchString(sstr)\n
...@@ -114,13 +116,11 @@ modemap = {\'natural\':0, \'boolean\':\'in_boolean_mode\', \'expanded\':\'with_q ...@@ -114,13 +116,11 @@ modemap = {\'natural\':0, \'boolean\':\'in_boolean_mode\', \'expanded\':\'with_q
if mode and modemap.has_key(mode):\n if mode and modemap.has_key(mode):\n
args[\'search_mode\'] = modemap[mode]\n args[\'search_mode\'] = modemap[mode]\n
\n \n
kw.update(args)\n
\n
# a hack because SQLCatalog wants table.key now \n # a hack because SQLCatalog wants table.key now \n
# dunno if it is a bug or a feature\n # dunno if it is a bug or a feature\n
if kw.has_key(\'SearchableText\'):\n if args.has_key(\'SearchableText\'):\n
kw[\'full_text.SearchableText\'] = kw[\'SearchableText\']\n args[\'full_text.SearchableText\'] = args[\'SearchableText\']\n
kw.pop(\'SearchableText\')\n args.pop(\'SearchableText\')\n
\n \n
cf = kw.get(\'creation_from\')\n cf = kw.get(\'creation_from\')\n
ct = kw.get(\'creation_to\')\n ct = kw.get(\'creation_to\')\n
...@@ -137,17 +137,16 @@ if mf:\n ...@@ -137,17 +137,16 @@ if mf:\n
if mt:\n if mt:\n
wheres.append(\'modification_date<"\' + cf.strftime(\'%Y-%m-%d\') + \'"\')\n wheres.append(\'modification_date<"\' + cf.strftime(\'%Y-%m-%d\') + \'"\')\n
if wheres != []:\n if wheres != []:\n
kw[\'where_expression\'] = \' AND \'.join(wheres)\n args[\'where_expression\'] = \' AND \'.join(wheres)\n
\n \n
# now we search\n # now we search\n
# any language?\n # any language?\n
if kw.get(\'language\') == \'0\': kw.pop(\'language\')\n if args.get(\'language\') == \'0\': args.pop(\'language\')\n
context.log(\'SEARCH:\',args)\n context.log(\'SEARCH:\',args)\n
res = context.portal_catalog(**kw)\n res = context.portal_catalog(**args)\n
\n \n
# user wants only his documents\n # user wants only his documents\n
if args.get(\'mine\'): \n if args.get(\'mine\'): \n
context.log(\'mine\')\n
from AccessControl import getSecurityManager\n from AccessControl import getSecurityManager\n
sm = getSecurityManager()\n sm = getSecurityManager()\n
u = sm.getUser()\n u = sm.getUser()\n
...@@ -158,7 +157,6 @@ if args.get(\'mine\'): \n ...@@ -158,7 +157,6 @@ if args.get(\'mine\'): \n
#...and now we check for only the newest versions\n #...and now we check for only the newest versions\n
# but we need to preserve order\n # but we need to preserve order\n
if args.get(\'newest\'):\n if args.get(\'newest\'):\n
context.log(\'newest\')\n
idx = {} # for keeping the last version of every reference\n idx = {} # for keeping the last version of every reference\n
# this way we do reduce the number of docs very fast (without calling catalog)\n # this way we do reduce the number of docs very fast (without calling catalog)\n
newest = [] # for keeping order as it was\n newest = [] # for keeping order as it was\n
......
483 487
\ 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