Re: empty passed to All -> 'Please Enter a Value'

Ian Bicking <[email protected]> Fri, 13 Jun 2008 18:04:11 -0500
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Ian Bicking wrote:
> Hrm... it seems All subclasses FancyValidator, which has an empty check, 
> so All(..., messages=dict(empty='yeah yeah')) would do it.
> 
> This isn't ideal.  I think maybe Mark was thinking of implementing a 
> better All though (All also has the ordering all wrong)...?  Might be 
> better to fix it there.

Actually it looks like there's some perhaps-unnecessary cleverness in there:

     def not_empty__get(self):
         not_empty = False
         for validator in self.validators:
             not_empty = not_empty or getattr(validator, 'not_empty', False)
         return not_empty
     not_empty = property(not_empty__get)

So it inherits the not-emptiness from its children, but doesn't inherit 
their messages.


-- 
Ian Bicking : [email protected] : http://blog.ianbicking.org

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php