Using validators

"Mike Orr" <[email protected]>
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
I've got a few questions about validators.  The FormEncode docs are
great for explaining how the validators work, but they don't say which
ones are best for various input controls.  I've also got a couple
complex situations.

1) What's the right validator for a checkbox?  I'm using
StringBoolean(), and it says "Missing value" unless the box is
checked.  Which is great if the box is labelled "Transfer $1,000,000
into Mike's bank account", but not for other things.

2) Submit buttons should be String?  And hidden values too?

3) I notice String returns unicode, at least in Pylons with the form
set to utf-8.  Hopefully it will remain that way.

4) My forms have a second submit button labeled Cancel, which simply
does a redirect to an appropriate place.  I could make this a
hyperlink but would like to keep it a button.  I need to bypass all
the other validators if Cancel is pressed because their value doesn't
matter.  How would I set this up?

5) I need to make an attachment widget that's simply an upload control
if there's no existing attachment.  But if there is an existing
attachment, it needs to show its info and thumbnail, radio buttons for
"keep", "replace with...", "delete", and an upload control for
replacement.  In Quixote I used a composite widget that returned a
tuple.  How would I make a validator for this?  How would I set up the
dict-dot feature for:

    fieldname.file => file upload control
    fieldname.action => radiobutton value ("keep", "replace",
"delete"), or hidden value ("add")

-- 
Mike Orr <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.