overriding validate_python (and similar methods) in validators
"Jacob Smullyan" <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Hello. I'm a bit new to FormEncode, so pardon me if I'm bringing up an old chestnut or need to be set straight about something. I recently had a bunch of custom validators, subclassing FancyValidator or one of its subclasses (Regex, for instance), and then I found a bug in one of them -- I overrode validate_python but didn't call the same method on the superclass, so didn't get the complete validation. (I believe this was a Regex subclass.) So I went through my validators and made sure that whenever I wrote a validate_python method, I called the corresponding superclass method. Then I tried running it, and whoah! for some but not all of the validators, this gave rise to an error, because validate_python in FancyValidator is None. I take it that the reason FormEncode allows validate_python et al to have the value of None is to support a declarative programming style. But to my mind the use of this feature in FancyValidator, a base class, makes the interface it presents rather confusing and unpredictable, and, I think, results in an excessively leaky abstraction. Couldn't these methods be defined there as noops, or would that have side-effects I'm unaware of? js -- Jacob Smullyan office: 212/669-3230 mobile: 917/576-5274 ------------------------------------------------------------------------- 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