Commits

Gael Pasgrimaud committed 7fea428

use LargeBinary

Comments (0)

Files changed (7)

         fatypes.DateTime: fields.DateTimeFieldRenderer,
         fatypes.Date: fields.DateFieldRenderer,
         fatypes.Time: fields.TimeFieldRenderer,
-        fatypes.Binary: fields.FileFieldRenderer,
+        fatypes.LargeBinary: fields.FileFieldRenderer,
         fatypes.List: fields.SelectFieldRenderer,
         fatypes.Set: fields.SelectFieldRenderer,
         'dropdown': fields.SelectFieldRenderer,

formalchemy/fatypes.py

 # This module is part of FormAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from sqlalchemy.types import TypeEngine, Integer, Float, String, Unicode, Text, Binary, Boolean, Date, DateTime, Time, Numeric, Interval
+from sqlalchemy.types import TypeEngine, Integer, Float, String, Unicode, Text, Boolean, Date, DateTime, Time, Numeric, Interval
 
-sa_types = set([Integer, Float, String, Unicode, Text, Binary, Boolean, Date, DateTime, Time, Numeric, Interval])
+try:
+    from sqlalchemy.types import LargeBinary
+except ImportError:
+    # SA < 0.6
+    from sqlalchemy.types import Binary as LargeBinary
+
+sa_types = set([Integer, Float, String, Unicode, Text, LargeBinary, Boolean, Date, DateTime, Time, Numeric, Interval])
 
 class List(TypeEngine):
     def get_dbapi_type(self):

formalchemy/fields.py

               field name
 
         - `type=types.String`:
-              data type, from formalchemy.types (Integer, Float, String, Binary,
-              Boolean, Date, DateTime, Time) or a custom type
+              data type, from formalchemy.types (Integer, Float, String,
+              LargeBinary, Boolean, Date, DateTime, Time) or a custom type
 
         - `value=None`:
               default value.  If value is a callable, it will be passed the current

formalchemy/tests/__init__.py

 class Binaries(Base):
     __tablename__ = 'binaries'
     id = Column(Integer, primary_key=True)
-    file = Column(Binary, nullable=True)
+    file = Column(LargeBinary, nullable=True)
 
 class ConflictNames(Base):
     __tablename__ = 'conflict_names'

formalchemy/tests/test_binary.py

 
 __doc__ = r"""
 
-Notice that those tests assume that the FileFieldRenderer work with Binary type
+Notice that those tests assume that the FileFieldRenderer work with LargeBinary type
 *and* String type if you only want to store file path in your DB.
 
 Configure a fieldset with a file field

formalchemy/tests/test_dates.py

 >>> fs.validate()
 False
 >>> fs.errors
-{AttributeField(foo): [ValidationError('Invalid date',)]}
+{AttributeField(foo): ['Invalid date']}
 
 >>> fs.rebind(dt, data={'Dt--foo__day': 'DD', 'Dt--foo__month': 'MM', 'Dt--foo__year': 'YYYY', 'Dt--bar__hour': 'HH', 'Dt--bar__minute': '1', 'Dt--bar__second': 'SS', 'Dt--foobar__day': 'DD', 'Dt--foobar__month': 'MM', 'Dt--foobar__year': '', 'Dt--foobar__hour': 'HH', 'Dt--foobar__minute': 'MM', 'Dt--foobar__second': 'SS'})
 >>> fs.validate()
 False
 >>> fs.errors
-{AttributeField(bar): [ValidationError('Invalid time',)]}
+{AttributeField(bar): ['Invalid time']}
 
 >>> fs.rebind(dt, data={'Dt--foo__day': 'DD', 'Dt--foo__month': 'MM', 'Dt--foo__year': 'YYYY', 'Dt--bar__hour': 'HH', 'Dt--bar__minute': 'MM', 'Dt--bar__second': 'SS', 'Dt--foobar__day': '11', 'Dt--foobar__month': '2', 'Dt--foobar__year': '1951', 'Dt--foobar__hour': 'HH', 'Dt--foobar__minute': 'MM', 'Dt--foobar__second': 'SS'})
 >>> fs.validate()
 False
 >>> fs.errors
-{AttributeField(foobar): [ValidationError('Incomplete datetime',)]}
+{AttributeField(foobar): ['Incomplete datetime']}
 """
 
 if __name__ == '__main__':

formalchemy/tests/test_fieldset.py

 >>> fs_2.validate()
 False
 >>> fs_2.errors
-{AttributeField(foo): [ValidationError('Value is not an integer',)]}
+{AttributeField(foo): ['Value is not an integer']}
 >>> print fs_2.render()
 <div>
  <label class="field_req" for="Two--foo">
 >>> fs_1.validate()
 False
 >>> fs_1.errors
-{AttributeField(id): [ValidationError('Value is not an integer',)]}
+{AttributeField(id): ['Value is not an integer']}
 
 # test updating _bound_pk copy
 >>> one = One(id=1)