unicode in URI

104 views
Skip to first unread message

Максим Коринец

unread,
Jan 22, 2012, 3:11:11 AM1/22/12
to pylons-...@googlegroups.com
Hi erveryone!

In my mako template I generate some url like this:

... href="${request.route_url('recipe', title=recipe.title)}"

where recipe.title is a unicode (cyrillic actially) string. Pyramid generates a correct url: http://localhost:6543/recipe/%D0%BE%D0%BB%D0%B8%D0%B2%D1%8C%D0%B5. When then I click on that link I see an error page - blank screen with message "A server error occurred. Please contact the administrator." The console output ends with these lines:

...
  File "/home/yentsun/env/local/lib/python2.7/site-packages/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/panels/templates/headers.jinja2", line 13, in top-level template code
    <td>{{ value|escape }}</td>
  File "/home/yentsun/env/local/lib/python2.7/site-packages/MarkupSafe-0.15-py2.7.egg/markupsafe/_native.py", line 21, in escape
    return Markup(unicode(s)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 8: ordinal not in range(128)
localhost - - [22/Jan/2012 12:01:26] "GET /recipe/%D0%BE%D0%BB%D0%B8%D0%B2%D1%8C%D0%B5 HTTP/1.1" 500 59

It seems like a similar problem described in this unanswered stackoverflow question. So is this a bug or I need something else to do to process unicode URI?

Thanks in advance, 
Max.

Chris McDonough

unread,
Jan 22, 2012, 9:17:24 AM1/22/12
to pylons-...@googlegroups.com
Can you please try upgrading pyramid_debugtoolbar to the most recent
version (0.9.8)

> --
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/pLExWgwYcFEJ.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discuss
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.


Максим Коринец

unread,
Jan 22, 2012, 2:14:55 PM1/22/12
to pylons-...@googlegroups.com
Thanks Chris! The problem is gone.
Reply all
Reply to author
Forward
0 new messages