[Erp5-report] r26856 - in /erp5/trunk/products/ZSQLCatalog: ./ Interface/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 6 18:30:42 CEST 2009


Author: vincent
Date: Wed May  6 18:30:41 2009
New Revision: 26856

URL: http://svn.erp5.org?rev=26856&view=rev
Log:
Export an API to access SearchKey's parser from SQLCatalog.
Internal use this API too.
Update IQueryCatalog interface.

Modified:
    erp5/trunk/products/ZSQLCatalog/Interface/IQueryCatalog.py
    erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

Modified: erp5/trunk/products/ZSQLCatalog/Interface/IQueryCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/Interface/IQueryCatalog.py?rev=26856&r1=26855&r2=26856&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/Interface/IQueryCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/Interface/IQueryCatalog.py [utf8] Wed May  6 18:30:41 2009
@@ -214,3 +214,22 @@
       False otherwise.
     """
 
+  def parseSearchText(search_text, column=None, search_key=None, is_valid=None):
+    """
+      Parses given SearchText expression using given column's parser
+      (determined by the SearchKey it is configured to use by default), or
+      given SearchKey name.
+
+      search_text (string)
+        SearchText to parse.
+      column (string)
+        Column to use to determine which SearchKey to use for parsing.
+        Either this parameter or search_key must be provided.
+      search_key (string)
+        Name of the SearchKey to use for parsing.
+        Either this parameter or column must be provided.
+      if_valid (callback)
+        Callback method to use to decide wether an encountered column-ish
+        identifier in SearchText is a valid column.
+        If not provided, catalog schema will be used.
+    """

Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=26856&r1=26855&r2=26856&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Wed May  6 18:30:41 2009
@@ -1984,6 +1984,19 @@
           related_key_definition=related_key_definition,
           search_value=result)
     return result
+
+  def _parseSearchText(self, search_key, search_text, is_valid=None):
+    if is_valid is None:
+      is_valid = self.isValidColumn
+    return search_key.parseSearchText(search_text, is_valid)
+
+  def parseSearchText(self, search_text, column=None, search_key=None,
+                      is_valid=None):
+    if column is None and search_key is None:
+      raise ValueError, 'One of column and search_key must be different '\
+                        'from None'
+    return self._parseSearchText(self.getSearchKey(
+      column, search_key=search_key), search_text, is_valid=is_valid)
 
   @profiler_decorator
   def buildQuery(self, kw, ignore_empty_string=True, operator='and'):
@@ -2036,7 +2049,7 @@
           # String: parse using key's default search key.
           search_key = self.getColumnDefaultSearchKey(key)
           if search_key is not None:
-            abstract_syntax_tree = search_key.parseSearchText(value, self.isValidColumn)
+            abstract_syntax_tree = self._parseSearchText(search_key, value)
             if abstract_syntax_tree is None:
               # Parsing failed, create a query from the bare string.
               result = self.buildSingleQuery(key, value)




More information about the Erp5-report mailing list