Re: [FE-discuss] Getting the message key?

Top Page
Author: Ian Bicking
Date:  
To: formencode-discuss
Subject: Re: [FE-discuss] Getting the message key?
Felix Schwarz wrote:
> 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!


FormEncode clearly crosses that line already -- there's lots of language
embedded in the validators.

That line generally is crossed in the message method, which is another
way you could handle this. An ad hoc solution here seems reasonable to me.

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


That's true.

> 3. Very limited, because you can't add style sheets or additional div's
> in the view depending the error occurred.


You can use htmlfill to do a bit of this depending on whether there's
any error for a field (form:iferror), but yes, you can't do it based on
the particular error in the field.

   Ian

-------------------------------------------------------------------------
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@???
https://lists.sourceforge.net/lists/listinfo/formencode-discuss