Commit 02a0e9e5 authored by Bartek Górny's avatar Bartek Górny

Parsing search string for extra tricks

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9246 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 14324657
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ZSQLMethods.SQL</string>
<string>SQL</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_drop_dmsdocinfo</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>DROP TABLE dmsdocinfo</string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</klass>
<none/>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string>DROP TABLE dmsdocinfo</string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ZSQLMethods.SQL</string>
<string>SQL</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>uid</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>uid</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_uncatalog_dmsdocinfo</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM dmsdocinfo WHERE <dtml-sqltest uid op=eq type=int>
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</klass>
<none/>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM dmsdocinfo WHERE <dtml-sqltest uid op=eq type=int>
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ZSQLMethods.SQL</string>
<string>SQL</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>getOriginalFilename</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getPortalType</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>uid</string>
<string>getOriginalFilename</string>
<string>getPortalType</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid\r\n
getOriginalFilename\r\n
getPortalType</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_catalog_dmsdocinfo_list</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-let doc_list="[]">\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-if expr="getPortalType[loop_item] in (\'Text\',\'Spreadsheet\',\'Presentation\',\'Graphic\',\'DMS File\',\'DMS Pdf File\')">\n
<dtml-call expr="doc_list.append(loop_item)">\n
</dtml-if>\n
</dtml-in>\n
<dtml-if expr="_.len(doc_list) > 0">\n
REPLACE INTO\n
dmsdocinfo\n
VALUES\n
<dtml-in prefix="loop" expr="doc_list">\n
(\n
<dtml-sqlvar expr="uid[loop_item]" type="int">, \n
<dtml-sqlvar expr="getOriginalFilename[loop_item]" type="string" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
</dtml-if>\n
</dtml-let>
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</klass>
<none/>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-let doc_list="[]">\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-if expr="getPortalType[loop_item] in (\'Text\',\'Spreadsheet\',\'Presentation\',\'Graphic\',\'DMS File\',\'DMS Pdf File\')">\n
<dtml-call expr="doc_list.append(loop_item)">\n
</dtml-if>\n
</dtml-in>\n
<dtml-if expr="_.len(doc_list) > 0">\n
REPLACE INTO\n
dmsdocinfo\n
VALUES\n
<dtml-in prefix="loop" expr="doc_list">\n
(\n
<dtml-sqlvar expr="uid[loop_item]" type="int">, \n
<dtml-sqlvar expr="getOriginalFilename[loop_item]" type="string" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
</dtml-if>\n
</dtml-let>
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ZSQLMethods.SQL</string>
<string>SQL</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_col</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_create_dmsdocinfo</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>CREATE TABLE `dmsdocinfo` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`original_filename` varchar(255),\n
PRIMARY KEY `uid` (`uid`),\n
KEY `original_filename` (`original_filename`)\n
) TYPE = InnoDB;</string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</klass>
<none/>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string>CREATE TABLE `dmsdocinfo` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`original_filename` varchar(255),\n
PRIMARY KEY `uid` (`uid`),\n
KEY `original_filename` (`original_filename`)\n
) TYPE = InnoDB;</string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import re
# parsing defined here
r=re.compile('(\w+:"[^"]+"|\w+:[\w\-.]+)')
filetyper=lambda s:('original_filename','%%.%s' % s)
filestripper=lambda s: ('original_filename',s.replace('"',''))
paramsmap=dict(file=filestripper,type='portal_type',reference='reference',filetype=filetyper)
def analyze(params):
params['SearchableText']=''
def cutter(s):
ss=s.split(':')
if len(ss)==1:
params['SearchableText']+=ss[0]
if len(ss)==2:
try:
ps=paramsmap.get(ss[0])(ss[1])
params[ps[0]]=ps[1]
except TypeError:
if paramsmap.has_key(ss[0]):
params[paramsmap.get(ss[0])]=ss[1]
return cutter
def parseSearchString(searchstring):
params={}
l=r.split(searchstring)
print l
map(analyze(params),l)
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'
print parseSearchString(searchstring)
......@@ -502,6 +502,33 @@
<permission type='list'>
<name>WebDAV access</name>
</permission>
<permission type='list'>
<name>Zwiki: Add comments</name>
</permission>
<permission type='list'>
<name>Zwiki: Add pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Add wikis</name>
</permission>
<permission type='list'>
<name>Zwiki: Change page types</name>
</permission>
<permission type='list'>
<name>Zwiki: Delete pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Edit pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Rate pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Rename pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Reparent pages</name>
</permission>
</permission_list>
<portal_type>Document Module</portal_type>
<title>Document Module</title>
......
......@@ -502,6 +502,33 @@
<permission type='list'>
<name>WebDAV access</name>
</permission>
<permission type='list'>
<name>Zwiki: Add comments</name>
</permission>
<permission type='list'>
<name>Zwiki: Add pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Add wikis</name>
</permission>
<permission type='list'>
<name>Zwiki: Change page types</name>
</permission>
<permission type='list'>
<name>Zwiki: Delete pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Edit pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Rate pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Rename pages</name>
</permission>
<permission type='list'>
<name>Zwiki: Reparent pages</name>
</permission>
</permission_list>
<portal_type>Image Module</portal_type>
<title>Images</title>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>kw.update(context.parseSearchString(kw.get(\'SearchableText\',\'\')))\n
return context.portal_catalog(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DMS_getAdvancedSearchResults</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -211,7 +211,7 @@
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
<value> <int>40</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
......
......@@ -561,7 +561,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>portal_catalog</string> </value>
<value> <string>DMS_getAdvancedSearchResults</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ExternalMethod.ExternalMethod</string>
<string>ExternalMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_function</string> </key>
<value> <string>parseSearchString</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>searchUtils</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>parseSearchString</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2008-08-17 BG
Parsing search string for extra tricks
2006-08-14 BG
Server address from preferences; dms categories from preferences and managed with parallel list field;
......
75
\ No newline at end of file
86
\ No newline at end of file
......@@ -30,6 +30,7 @@ Graphic | view
Image Module | list_ui
Image Module | sort_on
Image Module | view
Preference | dms_preferences
Presentation | convert
Presentation | create_snapshot
Presentation | download
......
erp5_mysql/z0_drop_dmsdocinfo
erp5_mysql/z0_drop_email
erp5_mysql/z0_uncatalog_dmsdocinfo
erp5_mysql/z0_uncatalog_email
erp5_mysql/z_catalog_dmsdocinfo_list
erp5_mysql/z_catalog_email_list
erp5_mysql/z_create_dmsdocinfo
erp5_mysql/z_create_email
\ No newline at end of file
asSecurityGroupIdList
searchUtils
mailUtils
cutFound
asSecurityGroupId
\ 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