I was looking for a way of typecasting attributes that are mapped to Integer columns as Python integers without having to commit to the database first. On the IRC channel, I was pointed towards simple validators and the @validates decorator. While this works, implementing validation using this approach for all integer attributes across all classes seems inefficient.
I then looked into AttributeEvents with the idea of adding a listener to the base class, but I can't seem to figure out a way for have the listener listen to all attribute changes. The documentation <http://docs.sqlalchemy.org/en/latest/orm/events.html#sqlalchemy.orm.events.AttributeEvents.set> only gives examples for listening to specific attributes (see example code below pulled from documentation). from sqlalchemy import event @event.listens_for(SomeClass.some_attribute, 'set') def receive_set(target, value, oldvalue, initiator): # ... (event handling logic) ... Hence, I was wondering if any of you would have a clever and straightforward way of achieving type validation on all classes (at least for integers for now). Thanks! *Extra Information* Python 2.7.8 SQLAlchemy 0.9.8 Best regards, Bruno -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.