commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7030 - trunk/gnue-common/src/datasources


From: reinhard
Subject: [gnue] r7030 - trunk/gnue-common/src/datasources
Date: Tue, 15 Feb 2005 09:42:07 -0600 (CST)

Author: reinhard
Date: 2005-02-15 09:42:06 -0600 (Tue, 15 Feb 2005)
New Revision: 7030

Modified:
   trunk/gnue-common/src/datasources/GConditions.py
Log:
Fixed Boolean conversions.


Modified: trunk/gnue-common/src/datasources/GConditions.py
===================================================================
--- trunk/gnue-common/src/datasources/GConditions.py    2005-02-15 15:18:31 UTC 
(rev 7029)
+++ trunk/gnue-common/src/datasources/GConditions.py    2005-02-15 15:42:06 UTC 
(rev 7030)
@@ -1192,10 +1192,20 @@
         oldValue = v2
         chkValue = v1
 
+      # String to Boolean
+      if hasattr (types, "BooleanType") and \
+         isinstance (chkValue, types.BooleanType):
+        if oldValue.upper () in ['TRUE', 'T']:
+          newValue = True
+        elif oldValue.upper () in ['FALSE', 'F']:
+          newValue = False
+        else:
+          raise ConversionError, (oldValue, chkValue)
+  
       # String to Integer, Long or Float
-      if isinstance (chkValue, types.IntType) or \
-         isinstance (chkValue, types.LongType) or \
-         isinstance (chkValue, types.FloatType):
+      elif isinstance (chkValue, types.IntType) or \
+           isinstance (chkValue, types.LongType) or \
+           isinstance (chkValue, types.FloatType):
         try:
           if oldValue.upper () in ['TRUE', 'T']:
             newValue = 1
@@ -1225,6 +1235,34 @@
       else:
         raise ConversionRuleError, (oldValue, chkValue)
   
+    # Boolean conversions
+    elif hasattr (types, "BooleanType") and \
+         (isinstance (v1, types.BooleanType) or \
+          isinstance (v2, types.BooleanType)):
+      if isinstance (v1, types.BooleanType):
+        oldValue = v1
+        chkValue = v2
+      else:
+        oldValue = v2
+        chkValue = v1
+
+      # Boolean to Integer
+      if isinstance (chkValue, types.IntType):
+        if oldValue:
+          newValue = 1
+        else:
+          newValue = 0
+  
+      # Boolean to Long
+      if isinstance (chkValue, types.LongType):
+        if oldValue:
+          newValue = 1L
+        else:
+          newValue = 0L
+  
+      else:
+        raise ConversionRuleError, (oldValue, chkValue)
+  
     # Integer conversions
     elif isinstance (v1, types.IntType) or isinstance (v2, types.IntType):
       if isinstance (v1, types.IntType):
@@ -1241,13 +1279,6 @@
       elif isinstance (chkValue, types.LongType):
         newValue = long (oldValue)
   
-      elif hasattr (types, "BooleanType") and \
-           isinstance (chkValue, types.BooleanType):
-        if oldValue == 0:
-          newValue = False
-        else:
-          newValue = True
-  
       else:
         raise ConversionRuleError, (oldValue, chkValue)
   





reply via email to

[Prev in Thread] Current Thread [Next in Thread]