Re: Getting the message key?

Felix Schwarz <felix.schwarz-S0/[email protected]> Wed, 26 Mar 2008 18:55:08 +0100
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Ian Bicking wrote:
> How about:
> 
>   user_validator = ValidatorClass(messages={'notLoggedIn': 
> htmlfill.literal('Wrong password.  <a href="...">Did you forget your 
> password?</a>')})

That is certainly one fast way to workaround the problem but I don't want 
to be restricted to encode all additional information in the error message.

Some limitations I see:
1. Mixing view markup + business logic. Bad karma!
2. Often you need more information which should be (imho) only present in
    the view/controller. In your example you would need the link target.
    Either the validator becomes non-portable or it needs to understand the
    project configuration to get the URL prefix etc.
3. Very limited, because you can't add style sheets or additional div's
    in the view depending the error occurred.


So while I'm really appreciating your feedback, I'm looking for a general 
approach to solve that problem ("how to detect the error cause after 
validation), especially because I think (hope?) this is not a very special 
situation but very common one.

If you think about it, it's essentially more important stating the cause of 
the error than the actual error message. If the problem is reduced to the 
max, one could decide not to return any kind of error message but just the 
error cause so that the developer can use his own error messages.

I think I'm going to provide a spike solution for a few built-in 
validators. Its better discussing over real code. :-)

fs

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

_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/formencode-discuss
smime.p7s (application/x-pkcs7-signature, 3.2 KB) - not displayed