[Erp5-report] r19698 - /erp5/trunk/products/CMFCategory/CategoryTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Mar 5 13:19:06 CET 2008


Author: seb
Date: Wed Mar  5 13:19:03 2008
New Revision: 19698

URL: http://svn.erp5.org?rev=19698&view=rev
Log:
allow to specify what is the none value into sql when calling buildSQLSelector

Modified:
    erp5/trunk/products/CMFCategory/CategoryTool.py

Modified: erp5/trunk/products/CMFCategory/CategoryTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFCategory/CategoryTool.py?rev=19698&r1=19697&r2=19698&view=diff
==============================================================================
--- erp5/trunk/products/CMFCategory/CategoryTool.py (original)
+++ erp5/trunk/products/CMFCategory/CategoryTool.py Wed Mar  5 13:19:03 2008
@@ -1426,7 +1426,7 @@
 
     # SQL Expression Building
     security.declareProtected(Permissions.AccessContentsInformation, 'buildSQLSelector')
-    def buildSQLSelector(self, category_list, query_table='category'):
+    def buildSQLSelector(self, category_list, query_table='category', none_sql_value=None):
       """
         Returns an SQL selector expression from a list of categories
         We make here a simple method wich simply checks membership
@@ -1434,6 +1434,9 @@
         to generate a much more complex where_expression with table aliases
 
         List of lists
+
+        - none_sql_value is used in order to specify what is the None value into
+          sql tables
       """
       if isinstance(category_list, str):
         category_list = [category_list]
@@ -1446,10 +1449,14 @@
             category_uid = self.getCategoryUid(category)
             base_category_uid = self.getBaseCategoryUid(category)
             expression = ''
+            if none_sql_value is not None and category_uid is None:
+              category_uid = none_sql_value
             if category_uid is None:
               expression += '%s.category_uid is NULL' % query_table
             else:
               expression += '%s.category_uid = %s' % (query_table,category_uid)
+            if none_sql_value is not None and base_category_uid is None:
+              base_category_uid = none_sql_value
             if base_category_uid is None:
               expression += ' AND %s.base_category_uid is NULL' % query_table
             else:
@@ -1461,10 +1468,14 @@
             if single_sql_expr != '':
               category_uid = self.getCategoryUid(single_category)
               base_category_uid = self.getBaseCategoryUid(single_category)
+              if none_sql_value is not None and category_uid is None:
+                category_uid = none_sql_value
               if category_uid is None:
                 expression += '%s.category_uid is NULL' % query_table
               else:
                 expression += '%s.category_uid = %s' % (query_table,category_uid)
+              if none_sql_value is not None and base_category_uid is None:
+                base_category_uid = none_sql_value
               if base_category_uid is None:
                 expression += ' AND %s.base_category_uid is NULL' % query_table
               else:




More information about the Erp5-report mailing list