def do_convert(cls, value): if value in ("", None): return None # Convert to float first, since python does not allow casting strings with decimals to int ret = int(float(value)) if not objtypes.is_int_short(ret): raise OverflowError("Integer value too large") return ret
def do_convert(cls, value): # Just like Int.do_convert, but skips conversion via float. This also makes it work for Record # types, which override int() conversion to yield the row ID. Arbitrary values should not be # cast to ints as it results in false hits when converting numerical values to reference ids. if not value: return 0 if not isinstance(value, (int, Record)): raise TypeError("Cannot convert to Id type") ret = int(value) if not objtypes.is_int_short(ret): raise OverflowError("Integer value too large") return ret
def is_right_type(cls, value): return (isinstance(value, (int, long)) and not isinstance(value, bool) and objtypes.is_int_short(value))
def is_right_type(cls, value): return (isinstance(value, six.integer_types) and not isinstance(value, bool) and objtypes.is_int_short(value))