Commit 2614b60e authored by Bartek Górny's avatar Bartek Górny

Extended search functions (requires SQLCatalog patch)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9667 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0be09eec
......@@ -2,13 +2,17 @@
import re
# parsing defined here
r=re.compile('(\w+:"[^"]+"|\w+:[\w\-.]+)')
simulation_states=('released','public','submitted')
r=re.compile('(\w+:"[^"]+"|\w+:[\w/\-.]+)')
filetyper=lambda s:('source_reference','%%.%s' % s)
filestripper=lambda s: ('source_reference',s.replace('"',''))
paramsmap=dict(file=filestripper,type='portal_type',reference='reference',filetype=filetyper)
addarchived=lambda s: ('simulation_state',simulation_states+('archived',))
paramsmap=dict(file=filestripper,type='portal_type',reference='reference',filetype=filetyper,archived=addarchived,\
language='language',version='version')
def analyze(params):
params['SearchableText']=''
params['simulation_state']=simulation_states
def cutter(s):
ss=s.split(':')
if len(ss)==1:
......@@ -20,6 +24,8 @@ def analyze(params):
except TypeError:
if paramsmap.has_key(ss[0]):
params[paramsmap.get(ss[0])]=ss[1]
else:
params[ss[0]]=ss[1]
return cutter
def parseSearchString(searchstring):
......@@ -27,9 +33,10 @@ def parseSearchString(searchstring):
l=r.split(searchstring)
print l
map(analyze(params),l)
params['SearchableText']=params['SearchableText'].strip()
return params
if __name__=='__main__':
#searchstring='byle cisnie zego file:"ble ble.doc" filetype:doc type:Text poza tym reference:abc-def'
searchstring='byle "cisnie zego" file:"ble ble.doc" type:Text poza tym reference:abc-def'
searchstring='byle "cisnie zego" file:"ble ble.doc" type:Text poza tym reference:abc-def dupa:kwas/zbita'
print parseSearchString(searchstring)
......@@ -70,7 +70,17 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
kw.update(context.parseSearchString(kw.get(\'SearchableText\',\'\')))\n
args=context.parseSearchString(kw.get(\'SearchableText\',\'\'))\n
args[\'portal_type\']=context.getPortalDocumentTypeList()\n
cats=[]\n
bases=context.portal_categories.getBaseCategoryList()\n
for k,v in args.items():\n
if k in bases:\n
cats.append(\'/\'.join((k,v)))\n
if cats!=[]:\n
args[\'category\']=cats\n
context.log(\'args\',args)\n
kw.update(args)\n
\n
cf=kw.get(\'creation_from\')\n
ct=kw.get(\'creation_to\')\n
......@@ -137,13 +147,19 @@ return context.portal_catalog(**kw)\n
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>args</string>
<string>_write_</string>
<string>cats</string>
<string>bases</string>
<string>_getiter_</string>
<string>k</string>
<string>v</string>
<string>cf</string>
<string>ct</string>
<string>mf</string>
<string>mt</string>
<string>wheres</string>
<string>str</string>
<string>_write_</string>
<string>_apply_</string>
</tuple>
</value>
......
2006-09-05 BG
Extended search functions (requires SQLCatalog patch)
2006-08-30 BG
Added ImageDocument type; assigned types to group dms_document.
......
114
\ No newline at end of file
121
\ No newline at end of file
0.70
\ No newline at end of file
0.71
\ 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