From: Hendrik M. <hen...@gm...> - 2004-12-20 15:20:11
|
Hi everyone, what would be the "cleanest" way of doing data validation for new/updated SQLObjects? Basically, I want to apply some basic constraints on my data fields, things like checking for minimum string lengths, regular expression matching, and so on... and I can't (or don't want to) do it inside my RDBMS. (Which was suggested in another posting to this list, I believe.) Right now, I'm seeing three possibilities, none of which I currently have that nice and warm "that's the one!" feeling about: - overriding _init() -- but that won't do validation when updating single fields - overriding _set_*, but will that work when I create a new SQLObject through .__init__()? - setting _lazyUpdate to True and adding validation code to sync() or syncUpdate() Also, I just noticed SQLObject includes FormEncode, and Cols can have a validator attribute... is that where I could apply my own validators? (Not sure if this is a new feature since 0.6?) Thanks! - Hendrik |