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: Sun, 19 Oct 2003 07:46:46 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-appserver
Branch:         
Changes by:     Reinhard Mueller <address@hidden>       03/10/19 07:46:46

Modified files:
        src            : geasInstance.py 

Log message:
        Use "isinstance (x, y)" instead of "if type (x) == y".

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

Patches:
Index: gnue-appserver/src/geasInstance.py
diff -c gnue-appserver/src/geasInstance.py:1.29 
gnue-appserver/src/geasInstance.py:1.30
*** gnue-appserver/src/geasInstance.py:1.29     Sat Oct 18 19:10:39 2003
--- gnue-appserver/src/geasInstance.py  Sun Oct 19 07:46:45 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.29 2003/10/18 23:10:39 reinhard Exp $
  
  import types
  import mx.DateTime
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.30 2003/10/19 11:46:45 reinhard Exp $
  
  import types
  import mx.DateTime
***************
*** 55,64 ****
      # String property (the id is actually a string, too)
      if propertydef.gnue_type == "id" or \
         propertydef.gnue_type == "string":      
!       if type (value) == types.UnicodeType:
          # encode unicode values to utf-8 (normal case)
          return value.encode ('utf-8')
!       elif type (value) == types.StringType:
          # if not UnicodeType then return normal string
          return value
        else:
--- 55,64 ----
      # String property (the id is actually a string, too)
      if propertydef.gnue_type == "id" or \
         propertydef.gnue_type == "string":      
!       if isinstance (value, types.UnicodeType):
          # encode unicode values to utf-8 (normal case)
          return value.encode ('utf-8')
!       elif isinstance (value, types.StringType):
          # if not UnicodeType then return normal string
          return value
        else:
***************
*** 81,92 ****
        
      # Date property
      elif propertydef.gnue_type == "date":
!       if type (value) == mx.DateTime.DateTimeType: # DateTime DB field
          return value.date
!       elif type (value) == types.UnicodeType:   # String DB field w/ Unicode
          # TODO: Check if valid date
          return value.encode ('utf-8')
!       elif type (value) == types.StringType:    # String DB field w/o Unicode
          # TODO: Check if valid date
          return value
        else:
--- 81,92 ----
        
      # Date property
      elif propertydef.gnue_type == "date":
!       if isinstance (value, mx.DateTime.DateTimeType):
          return value.date
!       elif isinstance (value, types.UnicodeType):
          # TODO: Check if valid date
          return value.encode ('utf-8')
!       elif isinstance (value, types.StringType):
          # TODO: Check if valid date
          return value
        else:
***************
*** 95,106 ****
  
      # Time property
      elif propertydef.gnue_type == "time":
!       if type (value) == mx.DateTime.DateTimeType: # DateTime DB field
          return value.time
!       elif type (value) == types.UnicodeType:   # String DB field w/ Unicode
          # TODO: Check if valid time
          return value.encode ('utf-8')
!       elif type (value) == types.StringType:    # String DB field w/o Unicode
          # TODO: Check if valid time
          return value
        else:
--- 95,106 ----
  
      # Time property
      elif propertydef.gnue_type == "time":
!       if isinstance (value, mx.DateTime.DateTimeType):
          return value.time
!       elif isinstance (value, types.UnicodeType):
          # TODO: Check if valid time
          return value.encode ('utf-8')
!       elif isinstance (value, types.StringType):
          # TODO: Check if valid time
          return value
        else:
***************
*** 109,120 ****
  
      # Date/Time property
      elif propertydef.gnue_type == "datetime":
!       if type (value) == mx.DateTime.DateTimeType: # DateTime DB field
          return value.date + " " + value.time
!       elif type (value) == types.UnicodeType:   # String DB field w/ Unicode
          # TODO: Check if valid datetime
          return value.encode ('utf-8')
!       elif type (value) == types.StringType:    # String DB field w/o Unicode
          # TODO: Check if valid datetime
          return value
        else:
--- 109,120 ----
  
      # Date/Time property
      elif propertydef.gnue_type == "datetime":
!       if isinstance (value, mx.DateTime.DateTimeType):
          return value.date + " " + value.time
!       elif isinstance (value, types.UnicodeType):
          # TODO: Check if valid datetime
          return value.encode ('utf-8')
!       elif isinstance (value, types.StringType):
          # TODO: Check if valid datetime
          return value
        else:
***************
*** 168,174 ****
      # String property (the id is actually a string, too)
      elif propertydef.gnue_type == "id" or \
           propertydef.gnue_type == "string":      
!       if type (value) is not types.StringType:
          value = str (value)
        # decode unicode values from utf-8 
        value = unicode (value, 'utf-8')
--- 168,174 ----
      # String property (the id is actually a string, too)
      elif propertydef.gnue_type == "id" or \
           propertydef.gnue_type == "string":      
!       if not isinstance (value, types.StringType):
          value = str (value)
        # decode unicode values from utf-8 
        value = unicode (value, 'utf-8')




reply via email to

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