[TurboGears] #2337: RestController cannot handle non-ascii URLs

7 views
Skip to first unread message

TurboGears

unread,
Jun 18, 2009, 8:18:31 AM6/18/09
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 2.0rc1
Severity: major | Keywords:
------------------------+---------------------------------------------------
Having a RestController attached at /controller/, accessing
/controller/something will fire it's get_one() method with the rest of the
path ('something') passed as method args. This works fine when that
something is of ascii chars. If not, we have:

{{{
File '/home/myself/src/myproject/myproject/lib/base.py', line 35 in
__call__
return TGController.__call__(self, environ, start_response)
File '/usr/local/lib/python2.6/dist-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py', line 217 in
__call__
response = self._inspect_call(self.__before__)
File '/usr/local/lib/python2.6/dist-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py', line 107 in
_inspect_call
result = self._perform_call(func, args)
File '/usr/local/lib/python2.6/dist-
packages/TurboGears2-2.0-py2.6.egg/tg/controllers.py', line 792 in
_perform_call
controller, remainder, params = self._get_routing_info(routingArgs)
File '/usr/local/lib/python2.6/dist-
packages/TurboGears2-2.0-py2.6.egg/tg/controllers.py', line 462 in
_get_routing_info
controller, remainder = _object_dispatch(self, url_path)
File '/usr/local/lib/python2.6/dist-
packages/TurboGears2-2.0-py2.6.egg/tg/controllers.py', line 528 in
_object_dispatch
return _find_restful_dispatch(obj, parent, remainder)
File '/usr/local/lib/python2.6/dist-
packages/TurboGears2-2.0-py2.6.egg/tg/controllers.py', line 593 in
_find_restful_dispatch
if remainder and hasattr(obj, remainder[0]) and remainder[0] not in
['new', 'edit']:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2:
ordinal not in range(128)
}}}

So, accessing entities with Unicode PKs via this RestController is not
possible.

--
Ticket URL: <http://trac.turbogears.org/ticket/2337>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

TurboGears

unread,
Jun 27, 2009, 9:20:51 AM6/27/09
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 2.0.1
Severity: major | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Changes (by guest):

* version: 2.0rc1 => 2.0.1

--
Ticket URL: <http://trac.turbogears.org/ticket/2337#comment:1>

TurboGears

unread,
Nov 17, 2009, 9:03:47 AM11/17/09
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.1
Component: TurboGears | Version: 2.0.1
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Changes (by jorge.vargas):

* severity: major => normal
* milestone: => 2.1

Comment:

This is indeed a valid bug, however the fix should be to throw an error as
unicode URLs should status is not well known. see
http://stackoverflow.com/questions/155892/unicode-url-decoding for
example.

Therefore I think the RestController should assume all URLs are ASCII-
encoded and complain if they are not rather than, allowing the PK as the
OP intended.

--
Ticket URL: <http://trac.turbogears.org/ticket/2337#comment:2>

TurboGears

unread,
Jan 26, 2010, 9:15:55 PM1/26/10
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.1b2

Component: TurboGears | Version: 2.0.1
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Changes (by percious):

* milestone: 2.1 => 2.1b2

--
Ticket URL: <http://trac.turbogears.org/ticket/2337#comment:3>

TurboGears

unread,
Feb 22, 2010, 6:51:10 PM2/22/10
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.1b2
Component: TurboGears | Version: 2.0.1
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by rick446):

I've had some trouble reproducing this problem using WebTest -- it seems
that WebTest converts everything (including URLs) to str() when creating
the request. I tried reproducing by encoding the URL as UTF-8, but this
appears to work just fine. So without a failing test case, I'm not sure
what we can do here.

--
Ticket URL: <http://trac.turbogears.org/ticket/2337#comment:4>

TurboGears

unread,
Feb 23, 2010, 3:05:25 PM2/23/10
to turbogear...@googlegroups.com
#2337: RestController cannot handle non-ascii URLs
------------------------+---------------------------------------------------
Reporter: guest | Owner:
Type: defect | Status: closed

Priority: normal | Milestone: 2.1b2
Component: TurboGears | Version: 2.0.1
Severity: normal | Resolution: fixed
Keywords: |
------------------------+---------------------------------------------------
Changes (by percious):

* status: new => closed
* resolution: => fixed

Comment:

I tested this in 2.1 on FFx, Safari, curl, and wget and found it to work
(aside from unittesting) Closing....

--
Ticket URL: <http://trac.turbogears.org/ticket/2337#comment:5>

Reply all
Reply to author
Forward
0 new messages