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 @@ ...@@ -2,13 +2,17 @@
import re import re
# parsing defined here # 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) filetyper=lambda s:('source_reference','%%.%s' % s)
filestripper=lambda s: ('source_reference',s.replace('"','')) 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): def analyze(params):
params['SearchableText']='' params['SearchableText']=''
params['simulation_state']=simulation_states
def cutter(s): def cutter(s):
ss=s.split(':') ss=s.split(':')
if len(ss)==1: if len(ss)==1:
...@@ -20,6 +24,8 @@ def analyze(params): ...@@ -20,6 +24,8 @@ def analyze(params):
except TypeError: except TypeError:
if paramsmap.has_key(ss[0]): if paramsmap.has_key(ss[0]):
params[paramsmap.get(ss[0])]=ss[1] params[paramsmap.get(ss[0])]=ss[1]
else:
params[ss[0]]=ss[1]
return cutter return cutter
def parseSearchString(searchstring): def parseSearchString(searchstring):
...@@ -27,9 +33,10 @@ def parseSearchString(searchstring): ...@@ -27,9 +33,10 @@ def parseSearchString(searchstring):
l=r.split(searchstring) l=r.split(searchstring)
print l print l
map(analyze(params),l) map(analyze(params),l)
params['SearchableText']=params['SearchableText'].strip()
return params return params
if __name__=='__main__': 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" 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) print parseSearchString(searchstring)
...@@ -70,7 +70,17 @@ ...@@ -70,7 +70,17 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <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 \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,13 +147,19 @@ return context.portal_catalog(**kw)\n ...@@ -137,13 +147,19 @@ return context.portal_catalog(**kw)\n
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</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>cf</string>
<string>ct</string> <string>ct</string>
<string>mf</string> <string>mf</string>
<string>mt</string> <string>mt</string>
<string>wheres</string> <string>wheres</string>
<string>str</string> <string>str</string>
<string>_write_</string>
<string>_apply_</string> <string>_apply_</string>
</tuple> </tuple>
</value> </value>
......
2006-09-05 BG
Extended search functions (requires SQLCatalog patch)
2006-08-30 BG 2006-08-30 BG
Added ImageDocument type; assigned types to group dms_document. Added ImageDocument type; assigned types to group dms_document.
......
114 121
\ No newline at end of file \ No newline at end of file
0.70 0.71
\ 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