1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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