Package camelot :: Package camelot :: Package view :: Module field_attributes
[hide private]
[frames] | no frames]

Source Code for Module camelot.camelot.view.field_attributes

  1  #  ============================================================================ 
  2  # 
  3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 
  4  #  www.conceptive.be / project-camelot@conceptive.be 
  5  # 
  6  #  This file is part of the Camelot Library. 
  7  # 
  8  #  This file may be used under the terms of the GNU General Public 
  9  #  License version 2.0 as published by the Free Software Foundation 
 10  #  and appearing in the file LICENSE.GPL included in the packaging of 
 11  #  this file.  Please review the following information to ensure GNU 
 12  #  General Public Licensing requirements will be met: 
 13  #  http://www.trolltech.com/products/qt/opensource.html 
 14  # 
 15  #  If you are unsure which license is appropriate for your use, please 
 16  #  review the following information: 
 17  #  http://www.trolltech.com/products/qt/licensing.html or contact 
 18  #  project-camelot@conceptive.be. 
 19  # 
 20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 
 21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
 22  # 
 23  #  For use of this library in commercial applications, please contact 
 24  #  project-camelot@conceptive.be 
 25  # 
 26  #  ============================================================================ 
 27   
 28  """Default field attributes for various sqlalchemy column types""" 
 29   
 30  import sqlalchemy.types 
 31  import camelot.types 
 32  import datetime 
 33   
 34  from PyQt4 import QtGui 
 35  from controls.editors import * 
 36   
 37  _sqlalchemy_to_python_type_ = { 
 38                                  
 39    sqlalchemy.types.Boolean: lambda f: {'python_type': bool, 
 40                                         'editable': True, 
 41                                         'widget': QtGui.QCheckBox }, 
 42   
 43    sqlalchemy.types.BOOLEAN: lambda f: {'python_type': bool, 
 44                                         'editable': True, 
 45                                         'widget': QtGui.QCheckBox}, 
 46   
 47    sqlalchemy.types.Date: lambda f: {'python_type': datetime.date, 
 48                                      'format': 'dd-mm-YYYY', 
 49                                      'editable': True, 
 50                                      'min': None, 
 51                                      'max': None, 
 52                                      'widget': DateEditor }, 
 53   
 54    sqlalchemy.types.Float: lambda f: {'python_type': float, 
 55                                       'precision': f.precision, 
 56                                       'editable': True, 
 57                                       'min': None, 
 58                                       'max': None, 
 59                                       'widget': 'float'}, 
 60   
 61    sqlalchemy.types.Integer: lambda f: {'python_type': int, 
 62                                         'editable': True, 
 63                                         'min': None, 
 64                                         'max': None, 
 65                                         'widget': 'int'}, 
 66   
 67    sqlalchemy.types.INT: lambda f: {'python_type': int, 
 68                                     'editable': True, 
 69                                     'min': None, 
 70                                     'max': None, 
 71                                     'widget': 'int'}, 
 72   
 73    sqlalchemy.types.String: lambda f: {'python_type': str, 
 74                                        'length': f.length, 
 75                                        'editable': True, 
 76                                        'widget': 'str'}, 
 77   
 78    sqlalchemy.types.TEXT: lambda f: {'python_type': str, 
 79                                      'length': f.length, 
 80                                      'editable': True, 
 81                                      'widget': 'str'}, 
 82   
 83    sqlalchemy.types.Unicode: lambda f: {'python_type': str, 
 84                                         'length': f.length, 
 85                                         'editable': True, 
 86                                         'widget': 'str'}, 
 87   
 88    camelot.types.Image: lambda f: {'python_type': str, 
 89                                    'editable': True, 
 90                                    'widget': 'image'}, 
 91   
 92    camelot.types.Code: lambda f: {'python_type': str, 
 93                                   'editable': True, 
 94                                   'widget': 'code', 
 95                                   'parts': f.parts}, 
 96   
 97    camelot.types.IPAddress: lambda f: {'python_type': str, 
 98                                   'editable': True, 
 99                                   'widget': 'code', 
100                                   'parts': f.parts}, 
101                                                                     
102    camelot.types.VirtualAddress: lambda f:{'python_type':str, 
103                                            'editable':True, 
104                                            'widget':'virtual_address', 
105                                            }, 
106                                    
107    sqlalchemy.types.Time : lambda f: {'python_type':datetime.time, 
108                                       'editable':True, 
109                                       'widget':'time', 
110                                       'format':'hh:mm', 
111                                       'nullable':True}, 
112     
113    sqlalchemy.types.DateTime : lambda f: {'python_type':datetime.datetime, 
114                                           'editable':True, 
115                                           'widget':'time', 
116                                           'format':'dd-MM-yyyy hh:mm', 
117                                           'nullable':True, 
118                                           'widget':'datetime'}, 
119     
120  } 
121