Re: OneOf with deferred call on function?

Ian Bicking <[email protected]> Fri, 09 Jan 2009 23:51:01 -0600
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Iain Duncan wrote:
> Hi folks, I'm wanting to do the following
> 
> validator = OneOf( [ <list generated at call time> ] )
> 
> I was hoping this would work
> 
> validator = OneOf( get_valid_options )
> 
> but it doesn't. Is there something I'm missing to do the above?

Well... doesn't work.  You could, I suppose, do:

class OneOfMine(OneOf):
     get_valid_options = None
     @property
     def list(self):
         return self.get_valid_options()


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

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB