Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (c) 2009 Richard Boulton 2 # 3 # Permission is hereby granted, free of charge, to any person obtaining a copy 4 # of this software and associated documentation files (the "Software"), to deal 5 # in the Software without restriction, including without limitation the rights 6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 # copies of the Software, and to permit persons to whom the Software is 8 # furnished to do so, subject to the following conditions: 9 # 10 # The above copyright notice and this permission notice shall be included in 11 # all copies or substantial portions of the Software. 12 # 13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 # SOFTWARE. 20 r"""Processing for POST and PUT data. 21 22 """ 23 __docformat__ = "restructuredtext en" 24 25 import cgi 26 import StringIO 27 28 import overlaydict 2931 """Read data from the request input and store in raw_post_data attr. 32 33 """ 34 if request.content_length > 0: 35 content_length = request.content_length 36 buf = StringIO.StringIO() 37 while content_length > 0: 38 chunk = request.input.read(min(content_length, 65536)) 39 if not chunk: 40 break 41 buf.write(chunk) 42 content_length -= len(chunk) 43 request.raw_post_data = buf.getvalue() 44 buf.close() 45 else: 46 request.raw_post_data = ''4749 """Read and parse request body and add to request params. 50 51 """ 52 read_raw_post_data(request) 53 if request.content_type == 'application/x-www-form-urlencoded': 54 request.POST = cgi.parse_qs(request.raw_post_data) 55 request.params = overlaydict.OverlayDict(request.POST, request.GET) 56 elif request.content_type == 'text/json': 57 import jsonsupport 58 jsonsupport.parse_json_body(request)59 60 # vim: set fileencoding=utf-8 : 61
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun May 10 00:22:21 2009 | http://epydoc.sourceforge.net |