Background :
Choices passed to the field contains non-ascii characterset
On submit while comparing the input value with valid values--it raises
a invalid choice error
- this happens only when a choice with non-ascii character in choosen
My finding:
Django smart-unicodes(and encode to UTF-8) the input value before
comparing;
but "str" the valid value set ( Refer the under-scripted code )
[code]
google_appengine/lib/django/django/newforms/fields.py:ChoiceField
def clean(self, value):
"""
Validates that the input is in self.choices.
"""
value = super(ChoiceField, self).clean(value)
if value in EMPTY_VALUES:
value = u''
value = smart_unicode(value)
if value == u'':
return value
valid_values = set([str(k) for k, v in self.choices]) # line
causing the trouble
if value not in valid_values:
raise ValidationError(gettext(u'Select a valid choice.
That choice is not one of the available choices.'))
return value
[/code]
As far as I know the unicode represents the non-ascii character a one
char and str divides it in to multiple bytes and hence they do not
match; And once I change str to unicode or smart_unicode everything
works perfect.
How do I fix it on appengine -- as the code is part of appengine
source. Please suggest.
I feel others who internationalized their app must have also faced the
same issue.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---