Re: Getting the message key?

Andreas Klostermann <andreasklostermann-gM/[email protected]> Wed, 26 Mar 2008 19:57:11 +0100
Newsgroups gmane.comp.python.formencode
Message-ID <1206557831.8653.71.camel@andi-laptop>
> Which tutorial do you refer to?
www.formencode.org

> How can I differentiate the cases without looking at the error message? 
> Especially if you think of NestedVariables etc.

try:
	do_validation
except Invalid:
	handle_standard_invalid
except UserExists:
	tell_the_user
except UserNameInvalid:
	do_something_about that

> If you use ForEach, you get 
> only one state and one Invalid exception but I need the error cause
> for 
> every single validation failure.

try:
	do_validation
except Invalid, e:
	print e.unpack_errors()

I have to point out that this is all covered in the official
documentation.

> I'm currently in a project where bad api design is a no-go - this 
> architecture will (hopefully) last for several (>3-5) years.

Well, I was referring to bad API on the formencode. I find a few names
in there confusing or counter intuitive. If you intend to produce nice
API, there are google tech talks about API design, and quite a few good
Python related videos, for example the one about Python Design Patterns.



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace