Ok, this seems to do the trick for my use case, but I'd be curious to see if there's a better way or if there are things that should be fixed here.
from types import IntType, LongType from sqlalchemy.exc import ArgumentError from sqlalchemy import event from sqlalchemy.orm import mapper def _check_integral_type(target, value, oldvalue, initiator): if not isinstance(value, IntType) and not isinstance(value, LongType): raise ArgumentError("value is not numeric") return value @event.listens_for(mapper, "mapper_configured") def _setup_int_listeners(mapper, class_): for prop in mapper.iterate_properties: if hasattr(prop, 'columns'): if isinstance(prop.columns[0].type, Integer): event.listen(getattr(class_, prop.key), "set", _check_integral_type, retval=True) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.