Commit 0d0bf21d authored by Ivan Tyagov's avatar Ivan Tyagov

Deprecate 'advanced_search_text' &'quick_search_text' scriptable key.

Add 'search_text' scriptable key.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43796 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c07abfd1
...@@ -50,21 +50,12 @@ ...@@ -50,21 +50,12 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query\n <value> <string>from Products.ERP5Type.Log import log\n
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n from Products.ZSQLCatalog.SQLCatalog import Query\n
\n \n
if container.isAdvancedSearchText(value):\n # warn by logging (not possible use python\'s warn module in restricted environment)\n
# the text which was provided is not a simple value\n log("\'quick_search_text\' and \'advanced_search_text\' scriptable keys are deprecated. Use \'search_text\' instead.")\n
# and contains predicates such as portal_type:\n return Query(search_text=value)\n
query = Query(SearchableText=value)\n
else:\n
query = ComplexQuery(Query(title=value),\n
Query(reference=value),\n
Query(source_reference=value),\n
Query(destination_reference=value),\n
Query(SearchableText=value),\n
operator="OR")\n
return query\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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 encoding="cdata"><![CDATA[
"""\n
Search text query generator. Accepts a string and returns a ComplexQuery.\n
For example:\n
\n
search_text = DMS reference:bt5-dms version:001 language:bg mine:yes (portal_type:Presentation OR portal_type:File) created:12m contributor_title:%tyagov%\n
\n
will parse search_text and generate a complexQuery which will return all documents which:\n
- have full_text searchable text containing "DMS"\n
- have reference equal to bt5-dms\n
- have portal_type "Presentation" OR "File"\n
- are created within last 12 months\n
- are owned by current logged in user\n
- are contributed by given Person\'s title\n
- etc ..\n
"""\n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery, SimpleQuery\n
\n
parsed_dict = context.Base_parseSearchString(value)\n
full_text = parsed_dict.pop(\'searchabletext\')\n
\n
#context.log(parsed_dict)\n
\n
# use full_text scriptable key!\n
query_list = [Query(**{\'full_text\': full_text})]\n
\n
# XXX: "newest" ?\n
# XXX: get known columns rather than hard-code \n
for key in (\'reference\', \'version\', \'language\', \'portal_type\', \'contributor_title\'):\n
value = parsed_dict.get(key, None)\n
if value is not None:\n
query_list.append(Query(**{key: value}))\n
\n
# user wants only his documents\n
if parsed_dict.get(\'mine\', None) is not None:\n
query_list.append(Query(**{\'owner\': str(context.portal_membership.getAuthenticatedMember())}))\n
\n
creation_from = parsed_dict.get(\'creation_from\', None)\n
creation_to = parsed_dict.get(\'creation_to\', None)\n
modification_from = parsed_dict.get(\'modification_from\', None)\n
modification_to = parsed_dict.get(\'modification_to\', None)\n
\n
if creation_from is not None:\n
query_list.append(SimpleQuery(**{\'catalog.creation_date\': creation_from, \n
\'comparison_operator\': \'>=\'}))\n
if creation_to is not None:\n
query_list.append(SimpleQuery(**{\'catalog.creation_date\': creation_to, \n
\'comparison_operator\': \'=<\'}))\n
if modification_from is not None:\n
query_list.append(SimpleQuery(**{\'catalog.modification_date\': modification_from, \n
\'comparison_operator\': \'>=\'}))\n
if modification_to is not None:\n
query_list.append(SimpleQuery(**{\'catalog.modification_date\': modification_to, \n
\'comparison_operator\': \'<=\'}))\n
return ComplexQuery(query_list, operator="AND")\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>value</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SQLCatalog_makeSearchTextQuery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
<key>advanced_search_text | SQLCatalog_makeQuickSearchQuery</key> <key>advanced_search_text | SQLCatalog_makeQuickSearchQuery</key>
<key>full_text | SQLCatalog_makeFullTextQuery</key> <key>full_text | SQLCatalog_makeFullTextQuery</key>
<key>quick_search_text | SQLCatalog_makeQuickSearchQuery</key> <key>quick_search_text | SQLCatalog_makeQuickSearchQuery</key>
<key>search_text | SQLCatalog_makeSearchTextQuery</key>
</key_list> </key_list>
\ No newline at end of file
2011-02-28 Ivan
* Deprecate 'advanced_search_text' &'quick_search_text' scriptable key
* Add 'search_text' scriptable key
2011-02-04 Nicolas 2011-02-04 Nicolas
* add children_reference related column * add children_reference related column
......
214 216
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,7 @@ erp5_mysql_innodb/SQLCatalog_catalogTransformation ...@@ -2,6 +2,7 @@ erp5_mysql_innodb/SQLCatalog_catalogTransformation
erp5_mysql_innodb/SQLCatalog_catalogTransformationList erp5_mysql_innodb/SQLCatalog_catalogTransformationList
erp5_mysql_innodb/SQLCatalog_makeFullTextQuery erp5_mysql_innodb/SQLCatalog_makeFullTextQuery
erp5_mysql_innodb/SQLCatalog_makeQuickSearchQuery erp5_mysql_innodb/SQLCatalog_makeQuickSearchQuery
erp5_mysql_innodb/SQLCatalog_makeSearchTextQuery
erp5_mysql_innodb/z0_drop_alarm erp5_mysql_innodb/z0_drop_alarm
erp5_mysql_innodb/z0_drop_catalog erp5_mysql_innodb/z0_drop_catalog
erp5_mysql_innodb/z0_drop_category erp5_mysql_innodb/z0_drop_category
......
quick_search_text | SQLCatalog_makeQuickSearchQuery quick_search_text | SQLCatalog_makeQuickSearchQuery
advanced_search_text | SQLCatalog_makeQuickSearchQuery advanced_search_text | SQLCatalog_makeQuickSearchQuery
full_text | SQLCatalog_makeFullTextQuery full_text | SQLCatalog_makeFullTextQuery
search_text | SQLCatalog_makeSearchTextQuery
\ 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