There are two issues here:
- your layout specifies a wrong encoding. It should be utf8 instead it is
probably submitting the form in latin1.
- the error should be detected and reported more gracefully (as a
validation error?)
Please open a a ticket about this.
On Sunday, 28 October 2012 04:23:41 UTC-5, Hono wrote:
>
>
> Le samedi 27 octobre 2012 21:45:09 UTC+2, Massimo Di Pierro a écrit :
>>
>> What error do you get?
>>
>> On Saturday, 27 October 2012 04:03:38 UTC-5, Hono wrote:
>>>
>>> Running the web2py version 2.2.1
>>> Define a Field with the unique constraint.
>>> Validation failed for unicode string like 'légère'.
>>>
>>
>
> In the model:
>
> db.define_table("countries",
> Field("country", "string", notnull=True, unique=True),
> migrate="countries.table")
>
> Later on, the values provide by the user, for example "Grèce", are
> validated.
> Then, the code crash with the following dump:
>
> Traceback (most recent call last):
> File "applications/myapp/modules/plugin_dbui/directsvc.py", line 130, in
> route
> di['result'] = self.procedures[k](*arg['data'])
> File "/home/hono/myweb/web2py/applications/myapp/models/plugin_dbui.py",
> line 85, in create
> return dbSvc.create(data)
> File "applications/myapp/modules/plugin_dbui/dbsvc.py", line 261, in
> create
> fields = self._get_fields(arg)
> File "applications/myapp/modules/plugin_dbui/dbsvc.py", line 172, in
> _get_fields
> di = self._is_fields_values_valid(table, fields)
> File "applications/myapp/modules/plugin_dbui/dbsvc.py", line 222, in
> _is_fields_values_valid
> errmsg = db[table][field].validate(val)[1]
> File "/home/hono/myweb/web2py/gluon/dal.py", line 8616, in validate
> (value, error) = validator(value)
> File "/home/hono/myweb/web2py/gluon/validators.py", line 578, in __call__
> value = str(value)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
> position 2: ordinal not in range(128)
>
>
--