ccgreen13 / gui2py

Automatically exported from code.google.com/p/gui2py
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Non ASCII text input raises UnicodeEncodeError in example form #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a table insert form with the gui2py form example
2. Pass non ascii data to the wx text fields in the html widget

What is the expected output? What do you see instead?

A web2py error is shown in terminal:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 7: 
ordinal not in range(128)

Please use labels and text to provide additional information.

Not sure, but i think it is only reproduced when using the PostgreSQL db engine.

System Info:
Mandriva GNU/Linux, PostgreSQL 8.4, web2py 1.99.2, Python 2.6.5, gui2py hg 
project clone

Here is the Python error message.

#####################################################

Traceback (most recent call last):
  File "/home/alan/gestionlibre_gui-hg/controllers/appadmin.py", line 191, in create
    if config.session.form.accepts(evt.args, formname=None, keepvalues=False, dbio=False):
  File "/home/alan/web2py/gluon/sqlhtml.py", line 1075, in accepts
    hideerror=hideerror,
  File "/home/alan/web2py/gluon/html.py", line 1798, in accepts
    status = self._traverse(status,hideerror)
  File "/home/alan/web2py/gluon/html.py", line 743, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/alan/web2py/gluon/html.py", line 743, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/alan/web2py/gluon/html.py", line 743, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/alan/web2py/gluon/html.py", line 743, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/alan/web2py/gluon/html.py", line 750, in _traverse
    newstatus = self._validate()
  File "/home/alan/web2py/gluon/html.py", line 1566, in _validate
    (value, errors) = validator(value)
  File "/home/alan/web2py/gluon/validators.py", line 530, in __call__
    value=str(value)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 7: 
ordinal not in range(128)

Original issue reported on code.google.com by spame...@gmail.com on 30 Nov 2011 at 3:36

GoogleCodeExporter commented 9 years ago
Looking again in the error trace, it seems not to be related to gui2py, but to 
unicode issues with web2py input. Perhaps this is not a valid gui2py issue.

Original comment by spame...@gmail.com on 30 Nov 2011 at 3:43

GoogleCodeExporter commented 9 years ago
It seems that web2py form validation requires str objects instead of unicode.

Original comment by spame...@gmail.com on 20 Dec 2011 at 1:56

GoogleCodeExporter commented 9 years ago
Now, gui2py encodes unicode input as UTF-8 for web2py compatibility

Original comment by spame...@gmail.com on 31 Jan 2012 at 12:46