spiral-project / daybed

Form validation and data storage API
http://daybed.rtfd.org/
BSD 3-Clause "New" or "Revised" License
53 stars 8 forks source link

UnicodeDecodeError on POST /models #248

Closed Natim closed 9 years ago

Natim commented 9 years ago

I had this error trying to create this model:

{
    "definition": {
        "description": "Merci de passer vos commandes de vins ci-dessous",
        "fields": [
            {
                "annotationType": "title",
                "label": "Coordonn\u00e9es",
                "type": "annotation"
            },
            {
                "hint": "description",
                "label": "Pr\u00e9nom",
                "name": "prenom",
                "required": false,
                "type": "string"
            },
            {
                "hint": "description",
                "label": "Nom",
                "name": "nom",
                "required": false,
                "type": "string"
            },
            {
                "hint": "description",
                "label": "E-mail",
                "name": "e-mail",
                "required": false,
                "type": "string"
            },
            {
                "annotationType": "title",
                "label": "Quantit\u00e9 souhait\u00e9e",
                "type": "annotation"
            },
            {
                "annotationType": "paragraph",
                "label": "En nombre de bouteilles",
                "type": "annotation"
            },
            {
                "hint": "Rouge \u2014 12,50\u20ac",
                "label": "Month\u00e9lie 2012",
                "name": "monthelie-2012",
                "required": false,
                "type": "string"
            },
            {
                "hint": "Rouge \u2014 16,50\u20ac",
                "label": "Beaune \"Vieilles Vignes\"",
                "name": "beaune-vieilles-vignes",
                "required": false,
                "type": "string"
            },
            {
                "hint": "Rouge \u2014 34\u20ac",
                "label": "H\u00f4pitaux de Beaune",
                "name": "hopitaux-de-beaune",
                "required": false,
                "type": "string"
            },
            {
                "hint": "Blanc \u2014 20,50\u20ac",
                "label": "Meursault 2012",
                "name": "meursault-2012",
                "required": false,
                "type": "string"
            },
            {
                "hint": "Blanc \u2014 6.50",
                "label": "Bourgogne Aligot\u00e9 2013",
                "name": "bourgogne-aligote-2013",
                "required": false,
                "type": "string"
            }
        ],
        "submitButtonLabel": "Commander",
        "title": "Commande de vins"
    }
}
[Thu Oct 23 11:01:12 2014] mod_wsgi (pid=1417201): Exception occurred processing WSGI script '~/daybed/daybed.wsgi'.
[Thu Oct 23 11:01:12 2014] Traceback (most recent call last):
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/router.py", line 242, in __call__
[Thu Oct 23 11:01:12 2014]     response = self.invoke_subrequest(request, use_tweens=True)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/router.py", line 217, in invoke_subrequest
[Thu Oct 23 11:01:12 2014]     response = handle_request(request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/tweens.py", line 46, in excview_tween
[Thu Oct 23 11:01:12 2014]     response = view_callable(exc, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 385, in viewresult_to_response
[Thu Oct 23 11:01:12 2014]     result = view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/tweens.py", line 21, in excview_tween
[Thu Oct 23 11:01:12 2014]     response = handler(request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/router.py", line 163, in handle_request
[Thu Oct 23 11:01:12 2014]     response = view_callable(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 596, in __call__
[Thu Oct 23 11:01:12 2014]     return view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 329, in attr_view
[Thu Oct 23 11:01:12 2014]     return view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 305, in predicate_wrapper
[Thu Oct 23 11:01:12 2014]     return view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 245, in _secured_view
[Thu Oct 23 11:01:12 2014]     return view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 355, in rendered_view
[Thu Oct 23 11:01:12 2014]     result = view(context, request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
[Thu Oct 23 11:01:12 2014]     response = view(request)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/cornice/service.py", line 514, in wrapper
[Thu Oct 23 11:01:12 2014]     response = view_(request)
[Thu Oct 23 11:01:12 2014]   File "/nfs/http7/ionyse/daybed/daybed/daybed/views/models.py", line 106, in post_models
[Thu Oct 23 11:01:12 2014]     permissions=permissions)
[Thu Oct 23 11:01:12 2014]   File "/nfs/http7/ionyse/daybed/daybed/daybed/backends/couchdb/__init__.py", line 132, in put_model
[Thu Oct 23 11:01:12 2014]     definition_id, _ = self._db.save(doc)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/client.py", line 432, in save
[Thu Oct 23 11:01:12 2014]     _, _, data = func(body=doc, **options)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 563, in put_json
[Thu Oct 23 11:01:12 2014]     **params)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 578, in _request_json
[Thu Oct 23 11:01:12 2014]     headers=headers, **params)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 574, in _request
[Thu Oct 23 11:01:12 2014]     credentials=self.credentials)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 360, in request
[Thu Oct 23 11:01:12 2014]     resp = _try_request_with_retries(iter(self.retry_delays))
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 312, in _try_request_with_retries
[Thu Oct 23 11:01:12 2014]     return _try_request()
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 337, in _try_request
[Thu Oct 23 11:01:12 2014]     conn.endheaders(body)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 110, in endheaders
[Thu Oct 23 11:01:12 2014]     self._send_output(message_body)
[Thu Oct 23 11:01:12 2014]   File "~/daybed/var/venv/lib/python2.6/site-packages/couchdb/http.py", line 117, in _send_output
[Thu Oct 23 11:01:12 2014]     msg += message_body
[Thu Oct 23 11:01:12 2014] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 95: ordinal not in range(128)
Natim commented 9 years ago

So, we have tracked down the bug to the CouchDB backend core. See https://github.com/djc/couchdb-python/pull/247