[sqlalchemy] Re: Validators: Define at table / mapper level ?

2009-06-23 Thread Michael Bayer
AF wrote: Hello, Can validators be defined at table / mapper level? (Is it even a good idea?) I ask, since it's at the table definition layer that I define what datatypes my columns have, so it seems natural to place the policing function there as well. a table level validator would

[sqlalchemy] Re: Validators: Define at table / mapper level ?

2009-06-23 Thread allen.fowler
If you have mapper definitions separate from classes, theres nothing stopping you from adding attributes to the class over there, i.e. mapper(MyClass, mytable) MyClass.foo = some_validation_decorator(MyClass.foo) Personally I wouldn't bother (then again I use declarative for everything