commit-gnue
[Top][All Lists]
Advanced

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

gnue-appserver/src geasInstance.py


From: Reinhard Mueller
Subject: gnue-appserver/src geasInstance.py
Date: Sat, 18 Oct 2003 17:20:15 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-appserver
Branch:         
Changes by:     Reinhard Mueller <address@hidden>       03/10/18 17:20:15

Modified files:
        src            : geasInstance.py 

Log message:
        Always encode unicode into utf-8.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasInstance.py.diff?tr1=1.25&tr2=1.26&r1=text&r2=text

Patches:
Index: gnue-appserver/src/geasInstance.py
diff -c gnue-appserver/src/geasInstance.py:1.25 
gnue-appserver/src/geasInstance.py:1.26
*** gnue-appserver/src/geasInstance.py:1.25     Fri Oct 17 05:03:43 2003
--- gnue-appserver/src/geasInstance.py  Sat Oct 18 17:20:14 2003
***************
*** 19,27 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.25 2003/10/17 09:03:43 reinhard Exp $
  
  import types
  
  # 
=============================================================================
  # Instance class
--- 19,28 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.26 2003/10/18 21:20:14 reinhard Exp $
  
  import types
+ from mx import DateTime
  
  # 
=============================================================================
  # Instance class
***************
*** 82,87 ****
--- 83,139 ----
            raise Exception, ("Database returned invalid value '%s' for " + \
                              "property '%s'") % (s, propertyname)
        
+     elif propertydef.gnue_type == "date":
+       s = self._record.getField (propertydef.column)
+       print "get date:" + repr (s)
+       if s is None:                             # NULL
+         return ""
+       elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
+         # TODO: Check if valid date
+         return s.encode ('utf-8')
+       elif type (s) == types.StringType:        # String DB field w/o Unicode
+         # TODO: Check if valid date
+         return s
+       elif type (s) == DateTime.DateTimeType:   # DateTime DB field
+         return s.date
+       else:
+         raise Exception, ("Database returned invalid value '%s' for " + \
+                           "property '%s'") % (s, propertyname)
+ 
+     elif propertydef.gnue_type == "time":
+       s = self._record.getField (propertydef.column)
+       print "get time:" + repr (s)
+       if s is None:                             # NULL
+         return ""
+       elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
+         # TODO: Check if valid time
+         return s.encode ('utf-8')
+       elif type (s) == types.StringType:        # String DB field w/o Unicode
+         # TODO: Check if valid time
+         return s
+       elif type (s) == DateTime.DateTimeType:   # DateTime DB field
+         return s.time
+       else:
+         raise Exception, ("Database returned invalid value '%s' for " + \
+                           "property '%s'") % (s, propertyname)
+ 
+     elif propertydef.gnue_type == "datetime":
+       s = self._record.getField (propertydef.column)
+       print "get datetime:" + repr (s)
+       if s is None:                             # NULL
+         return ""
+       elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
+         # TODO: Check if valid datetime
+         return s.encode ('utf-8')
+       elif type (s) == types.StringType:        # String DB field w/o Unicode
+         # TODO: Check if valid datetime
+         return s
+       elif type (s) == DateTime.DateTimeType:   # DateTime DB field
+         return s.date + " " + s.time
+       else:
+         raise Exception, ("Database returned invalid value '%s' for " + \
+                           "property '%s'") % (s, propertyname)
+ 
      elif propertydef.gnue_type == "boolean":
        # Boolean property
        s = self._record.getField (propertydef.column)
***************
*** 104,110 ****
          return s
  
      # TODO: Missing property types:
-     #       * datetime
      #       * list properties
      #       * calculated properties (must have triggers working first)
  
--- 156,161 ----
***************
*** 145,150 ****
--- 196,210 ----
        # TODO: check if value is an number
        pass
        
+     elif propertydef.gnue_type == "date":
+       print "put date:" + repr (value)
+ 
+     elif propertydef.gnue_type == "time":
+       print "put time:" + repr (value)
+ 
+     elif propertydef.gnue_type == "datetime":
+       print "put datetime:" + repr (value)
+ 
      elif propertydef.gnue_type == "boolean":
        # Boolean property
        if value == "":




reply via email to

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