/[gnue]/gnue-appserver/src/geasInstance.py
ViewVC logotype

Diff of /gnue-appserver/src/geasInstance.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by reinhard, Fri Oct 17 09:03:43 2003 UTC revision 1.26 by reinhard, Sat Oct 18 21:20:14 2003 UTC
# Line 22  Line 22 
22  # $Id$  # $Id$
23    
24  import types  import types
25    from mx import DateTime
26    
27  # =============================================================================  # =============================================================================
28  # Instance class  # Instance class
# Line 82  class geasInstance: Line 83  class geasInstance:
83            raise Exception, ("Database returned invalid value '%s' for " + \            raise Exception, ("Database returned invalid value '%s' for " + \
84                              "property '%s'") % (s, propertyname)                              "property '%s'") % (s, propertyname)
85                
86        elif propertydef.gnue_type == "date":
87          s = self._record.getField (propertydef.column)
88          print "get date:" + repr (s)
89          if s is None:                             # NULL
90            return ""
91          elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
92            # TODO: Check if valid date
93            return s.encode ('utf-8')
94          elif type (s) == types.StringType:        # String DB field w/o Unicode
95            # TODO: Check if valid date
96            return s
97          elif type (s) == DateTime.DateTimeType:   # DateTime DB field
98            return s.date
99          else:
100            raise Exception, ("Database returned invalid value '%s' for " + \
101                              "property '%s'") % (s, propertyname)
102    
103        elif propertydef.gnue_type == "time":
104          s = self._record.getField (propertydef.column)
105          print "get time:" + repr (s)
106          if s is None:                             # NULL
107            return ""
108          elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
109            # TODO: Check if valid time
110            return s.encode ('utf-8')
111          elif type (s) == types.StringType:        # String DB field w/o Unicode
112            # TODO: Check if valid time
113            return s
114          elif type (s) == DateTime.DateTimeType:   # DateTime DB field
115            return s.time
116          else:
117            raise Exception, ("Database returned invalid value '%s' for " + \
118                              "property '%s'") % (s, propertyname)
119    
120        elif propertydef.gnue_type == "datetime":
121          s = self._record.getField (propertydef.column)
122          print "get datetime:" + repr (s)
123          if s is None:                             # NULL
124            return ""
125          elif type (s) == types.UnicodeType:       # String DB field w/ Unicode
126            # TODO: Check if valid datetime
127            return s.encode ('utf-8')
128          elif type (s) == types.StringType:        # String DB field w/o Unicode
129            # TODO: Check if valid datetime
130            return s
131          elif type (s) == DateTime.DateTimeType:   # DateTime DB field
132            return s.date + " " + s.time
133          else:
134            raise Exception, ("Database returned invalid value '%s' for " + \
135                              "property '%s'") % (s, propertyname)
136    
137      elif propertydef.gnue_type == "boolean":      elif propertydef.gnue_type == "boolean":
138        # Boolean property        # Boolean property
139        s = self._record.getField (propertydef.column)        s = self._record.getField (propertydef.column)
# Line 104  class geasInstance: Line 156  class geasInstance:
156          return s          return s
157    
158      # TODO: Missing property types:      # TODO: Missing property types:
     #       * datetime  
159      #       * list properties      #       * list properties
160      #       * calculated properties (must have triggers working first)      #       * calculated properties (must have triggers working first)
161    
# Line 145  class geasInstance: Line 196  class geasInstance:
196        # TODO: check if value is an number        # TODO: check if value is an number
197        pass        pass
198                
199        elif propertydef.gnue_type == "date":
200          print "put date:" + repr (value)
201    
202        elif propertydef.gnue_type == "time":
203          print "put time:" + repr (value)
204    
205        elif propertydef.gnue_type == "datetime":
206          print "put datetime:" + repr (value)
207    
208      elif propertydef.gnue_type == "boolean":      elif propertydef.gnue_type == "boolean":
209        # Boolean property        # Boolean property
210        if value == "":        if value == "":

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26