I find it's easy enough to just create new types from existing types to do the validation. e.g. I created a simple Enum type this way...
class Enum(types.Unicode): def __init__(self, values, empty_to_none=False): ''' contruct an Enum type values : a list of values that are valid for this column empty_to_none : treat the empty string '' as None ''' if values is None or len(values) is 0: raise exceptions.AssertionError('Enum requires a list of values') self.empty_to_none = empty_to_none self.values = values # the length of the string/unicode column should be the longest string # in values super(Enum, self).__init__(len(max(values))) def convert_bind_param(self, value, engine): if self.empty_to_none and value is '': value = None if value not in self.values: raise exceptions.AssertionError('%s not in Enum.values' % value) return super(Enum, self).convert_bind_param(value, engine) def convert_result_value(self, value, engine): if value not in self.values: raise exceptions.AssertionError('%s not in Enum.values' % value) return super(Enum, self).convert_result_value(value, engine) On Sat, 2006-07-22 at 13:24 +0200, Julien Cigar wrote: > SQLAlchemy uses new style classes, so you can use property() with > set/get methods (like in C#). Also, I think that things like validators > should not be implemented in an ORM tool, it's the task of the > programmer. The goal of an ORM is to map tables to classes, not to > validate fields or other things like that .. > > Viktor Kerkez wrote: > > I've just looked at SqlAlchemy, and liked it, but I'm curious if there > > is any concept of validators and manipulators similar to those found > > in Django's ORM, or I have to roll my own? > > > > For those not familiar with Django, for every column type Django have > > predefined validators, also you can define your own and add them to > > the validators list. Manipulators (simplified) take a mapped object, > > validate every column and save it, update it or return an appropriate > > error message... > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > opinions on IT & business topics through brief surveys -- and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Sqlalchemy-users mailing list > > Sqlalchemy-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users