URL percent encoding using urllib

32 views
Skip to first unread message

soujiro0725

unread,
Jul 23, 2012, 3:25:48 AM7/23/12
to google-a...@googlegroups.com
GAE for Python 1.7.0

 I am trying to pass chinese characters to the URL so that handlers recognize them through regular expressions.

the regular expression is 

CH_RE = u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]'

Hopefully the regular expression catches as follows

app = webapp2.WSGIApplication([('/?', MainPage), ('/_edit' + CH_RE, EditPageHandler)]


I tried an URL

http://localhost:8092/鶴

But it gives an error,

404 Not Found
The resource could not be found.

The log shows 

INFO     2012-07-23 07:10:34,546 dev_appserver.py:2952] "GET /%E9%B6%B4 HTTP/1.1" 404 - 

I am a little confused.  It looks like I need to encode the given URL so that the regular expression can at least read it.
The AppEngine seems to automatically execute percent encoding through the process.

It is hard to determine what to ask you all, but I believe that the problem is passing encoded URL to the main function.

The question is how and where in the code do I need to specify the encoding process?

I apologize for such a disorganized question, but I appreciate if anyone points out the problem more specifically.


 
Reply all
Reply to author
Forward
0 new messages