icook/yota — pull request #72 by xen (2013-08-19 12:47:26+00:00)
Title: UnicodeEncodeError if non ascii value is submited

If you fill form with non ascii symbols (for example russian) it fail with this traceback:

```
Traceback (most recent call last):
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/xen/Dev/water/cabinet/venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/xen/Dev/water/cabinet/water/registry/views.py", line 96, in contract
success, out = form.validate_render(request.form)
File "/Users/xen/Dev/water/cabinet/venv/src/yota/src/yota/__init__.py", line 513, in validate_render
block, invalid = self._gen_validate(data)
File "/Users/xen/Dev/water/cabinet/venv/src/yota/src/yota/__init__.py", line 388, in _gen_validate
check.validate()
File "/Users/xen/Dev/water/cabinet/venv/src/yota/src/yota/validators.py", line 411, in validate
return self.validator(*self.args, **self.kwargs)
File "/Users/xen/Dev/water/cabinet/venv/src/yota/src/yota/validators.py", line 47, in __call__
if len(str(target.data)) > self.max_length:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
```

I've fixed code that tries to convert unicode strings using str function. Not fully sure about py3 version, since I don't yet switched to in on this project. But for me it at least fixed problem with other languages.