[Zope-Checkins] SVN: Zope/trunk/ - ZSQL methods: added workaround for a problem where a 'string' argument

Andreas Jung andreas at andreas-jung.com
Mon Oct 11 07:34:16 EDT 2004


Log message for revision 27964:
       - ZSQL methods: added  workaround for a problem where a 'string' argument
         variable was included into the generated query if the 'optional' flag inside
         dtml-sqltest was set an if the value of the string was empty.
  


Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Shared/DC/ZRDB/sqltest.py


-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-10-11 11:22:51 UTC (rev 27963)
+++ Zope/trunk/doc/CHANGES.txt	2004-10-11 11:34:15 UTC (rev 27964)
@@ -27,6 +27,10 @@
 
     Features added
 
+     - ZSQL methods: added  workaround for a problem where a 'string' argument
+       variable was included into the generated query if the 'optional' flag inside
+       dtml-sqltest was set an if the value of the string was empty.
+
      - Included Stefan Holek's ZopeTestCase 0.9
 
      - The SiteErrorLog allows you to acknowledge (or delete) exceptions,

Modified: Zope/trunk/lib/python/Shared/DC/ZRDB/sqltest.py
===================================================================
--- Zope/trunk/lib/python/Shared/DC/ZRDB/sqltest.py	2004-10-11 11:22:51 UTC (rev 27963)
+++ Zope/trunk/lib/python/Shared/DC/ZRDB/sqltest.py	2004-10-11 11:34:15 UTC (rev 27964)
@@ -65,7 +65,7 @@
 #       rights reserved.
 #
 ############################################################################
-__version__='$Revision: 1.19 $'[11:-2]
+__version__='$Revision: 1.5 $'[11:-2]
 
 import sys
 from DocumentTemplate.DT_Util import ParseError, parse_params, name_param
@@ -115,7 +115,6 @@
         self.op = op
 
     def render(self, md):
-
         name=self.__name__
 
         t=self.type
@@ -159,6 +158,14 @@
                 except ValueError:
                     raise ValueError, (
                         'Invalid floating-point value for <em>%s</em>' % name)
+
+            ## ZSQL methods: added  workaround for a problem where a 'string' argument
+            ## variable was included into the generated query if the 'optional' flag inside
+            ## dtml-sqltest was set an if the value of the string was empty.
+
+            elif t=='string' and len(str(v)) == 0  and args.get('optional', 0):
+                continue
+
             else:
                 v=str(v)
                 v=md.getitem('sql_quote__',0)(v)
@@ -173,6 +180,7 @@
                 err = 'Invalid empty string value for <em>%s</em>' % name
                 raise ValueError, err
 
+
         if not vs:
             if self.optional: return ''
             raise ValueError, (



More information about the Zope-Checkins mailing list