On 2007-06-14 01:36:16 +0200, Christopher Arndt wrote:
> Michael Bienia schrieb:
> > I managed to format a decimal number with
> > turbogears.i18n.format.format_decimal() from my controller but how do I
> > do it from my template?
> 
> You could bind this function to a custom template variable. See thsi doc
> on how to do that:
> 
> http://docs.turbogears.org/1.0/stdvars#custom-additions
> 

Thanks, that worked.
I also discovered that I could simply add
"<?python from turbogears.i18n.format import format_decimal ?>"
to my template to be able to use it.

Are there disadvantages doing it this way?


> > How do I get forms to use localized numbers? Especially when I want to
> > edit a database record and pass the existing data to the form.
> 
> I think you would need to attach a custom validator with a 'from_python'
> method to the form field:
> 
> http://formencode.org/Validator.html#using-validation
> 
> Somebody correct me, if I'm wrong.

I already use a custom validator (extends the Number validator). I
defined a schema for the validation. The validation of submitted values
works.
Now I added also from_python() to my validator but it didn't worked.
Validation of my input still worked but the data from the database
didn't get formated.
I had to move the validator from the schema to the validator attribute
of the widget to get it working (and then even the inherited
from_python() worked).

Has someone an idea why it works when I add my validator to the widget
but not if I do it from a schema definition?

Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to