Re: letting file field pass through, validate other expected text fields?

Ian Bicking <[email protected]> Thu, 26 Jun 2008 14:13:31 -0500
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Kevin Mateo Lim wrote:
> hello,
> 
> hope you're well.
> 
> i'm just getting off the ground, and can't seem to find the answer to
> this simple question in the docs:
> 
> i'm writing a form that allows a person to upload a file, and give
> that file a title.
> 
> i'd like to 1) run form validation on the title field, making sure
> it's a string, 2) leave the file content alone, keeping it simple to
> retrieve, and 3) filter all extra fields, filter_extra_fields = True,
> so no other rogue fields get through.
> 
> can you help? because i'm stuck on this.  and i bet it's really simple.

class MySchema(Schema):
     title = formencode.validator.String()
     upload = formencode.api.Validator()
     filter_extra_fields = True


-- 
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