/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/transientdb.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/transientdb.py

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

revision 1026 by frank, Mon May 26 11:46:42 2003 UTC revision 1043 by bh, Mon May 26 19:27:15 2003 UTC
# Line 258  class TransientTableBase(table.OldTableI Line 258  class TransientTableBase(table.OldTableI
258              return None              return None
259    
260          if type == sql_type_map[table.FIELDTYPE_DOUBLE]:          if type == sql_type_map[table.FIELDTYPE_DOUBLE]:
261              prec = self.Precision(col)              format = "%.12f"
             format = "%%.%df" % prec  
262          elif type == sql_type_map[table.FIELDTYPE_INT]:          elif type == sql_type_map[table.FIELDTYPE_INT]:
263              format = "%d"              format = "%d"
264          else:          else:
# Line 272  class TransientTableBase(table.OldTableI Line 271  class TransientTableBase(table.OldTableI
271    
272          return max          return max
273    
     def Precision(self, col):  
         """Return the precision of the column  
   
         The return value is the maximum number of numeric characters after the  
         decimal if column type is double. Else precision zero is returned.  
         The column can be represented by index or name.  
         """  
       
         type  = self.column_map[col].type  
         if type == sql_type_map[table.FIELDTYPE_DOUBLE]:  
             iname = self.column_map[col].internal_name  
             cursor = self.db.cursor()  
             cursor.execute("SELECT %s FROM %s;" % (iname, self.tablename))  
             values = [ i[0] for i in cursor.fetchall()]  
             if not values:  
                 return 0  
               
             max = 0  
             for value in values:  
                 if value is None: continue  
                 l = len(str(value % 1))  
                 if l > max:  
                     max = l  
             if max > 2:  
                 return max - 2  
             else:  
                 return 0  
         else:  
             return 0  
   
274      def SimpleQuery(self, left, comparison, right):      def SimpleQuery(self, left, comparison, right):
275          """Return the indices of all rows that matching a condition.          """Return the indices of all rows that matching a condition.
276    
# Line 566  class AutoTransientTable(TitledObject, t Line 535  class AutoTransientTable(TitledObject, t
535          """Return a tuple containing the original table"""          """Return a tuple containing the original table"""
536          return (self.table,)          return (self.table,)
537    
538        def Width(self, col):
539            return self.table.Width(col)

Legend:
Removed from v.1026  
changed lines
  Added in v.1043

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26