david / django-roa (http://welldev.org/)
Turn your models into remote resources that you can access through Django's ORM. ROA stands for Resource Oriented Architecture.
| commit 119: | 7f0bf6ff404a |
| parent 118: | 7e9e0615c76f |
| branch: | default |
Update restkit to the latest tip to deal with a bug in headers' handling
12 months ago
Changed (Δ29 bytes):
raw changeset »
restkit/ext/eventlet_pool.py (1 lines added, 0 lines removed)
restkit/pool.py (1 lines added, 1 lines removed)
restkit/rest.py (12 lines added, 8 lines removed)
Up to file-list restkit/ext/eventlet_pool.py:
| … | … | @@ -20,6 +20,7 @@ from eventlet.green import socket |
20 |
20 |
from eventlet.green import httplib |
21 |
21 |
from eventlet.pools import Pool |
22 |
22 |
from eventlet.util import wrap_socket_with_coroutine_socket |
23 |
||
23 |
24 |
wrap_socket_with_coroutine_socket() |
24 |
25 |
|
25 |
26 |
def make_proxy_connection(uri): |
Up to file-list restkit/pool.py:
| … | … | @@ -186,7 +186,7 @@ class Pool(object): |
186 |
186 |
def waiting(self): |
187 |
187 |
"""Return the number of routines waiting for a pool item. |
188 |
188 |
""" |
189 |
return self. |
|
189 |
return self.max_size - self.channel.qsize() |
|
190 |
190 |
|
191 |
191 |
def create(self): |
192 |
192 |
"""Generate a new pool item |
Up to file-list restkit/rest.py:
| … | … | @@ -228,10 +228,9 @@ class Resource(object): |
228 |
228 |
:param _stream_size: int, size in bytes of response stream block |
229 |
229 |
:param params: Optionnal parameterss added to the request |
230 |
230 |
""" |
231 |
_headers = self._headers or {} |
|
232 |
_headers.update(headers or {}) |
|
231 |
||
233 |
232 |
return self.client.request(method, self.uri, path=path, |
234 |
body=payload, headers= |
|
233 |
body=payload, headers=headers, _stream=_stream, |
|
235 |
234 |
_stream_size=_stream_size, **params) |
236 |
235 |
|
237 |
236 |
def get_response(self): |
| … | … | @@ -400,7 +399,12 @@ class RestClient(object): |
400 |
399 |
""" |
401 |
400 |
|
402 |
401 |
# init headers |
403 |
|
|
402 |
||
403 |
if self._headers is not None: |
|
404 |
_headers = self._headers.copy() |
|
405 |
else: |
|
406 |
_headers = {} |
|
407 |
||
404 |
408 |
_headers.update(headers or {}) |
405 |
409 |
|
406 |
410 |
self._body_parts = [] |
| … | … | @@ -416,7 +420,7 @@ class RestClient(object): |
416 |
420 |
body = to_bytestring(body) |
417 |
421 |
size = len(body) |
418 |
422 |
elif isinstance(body, dict): |
419 |
content_type = |
|
423 |
content_type = _headers.get('Content-Type') |
|
420 |
424 |
if content_type is not None and content_type.startswith("multipart/form-data"): |
421 |
425 |
type_, opts = cgi.parse_header(content_type) |
422 |
426 |
boundary = opts.get('boundary', uuid.uuid4().hex) |
| … | … | @@ -426,8 +430,8 @@ class RestClient(object): |
426 |
430 |
body = form_encode(body) |
427 |
431 |
size = len(body) |
428 |
432 |
elif isinstance(body, MultipartForm): |
429 |
headers['Content-Type'] = "multipart/form-data; boundary=%s" % body.boundary |
|
430 |
headers['Content-Length'] = str(body.get_size()) |
|
433 |
_headers['Content-Type'] = "multipart/form-data; boundary=%s" % body.boundary |
|
434 |
_headers['Content-Length'] = str(body.get_size()) |
|
431 |
435 |
|
432 |
436 |
if 'Content-Length' not in _headers and size is not None: |
433 |
437 |
_headers['Content-Length'] = size |
| … | … | @@ -436,7 +440,7 @@ class RestClient(object): |
436 |
440 |
'the length of the data parameter. Specify a value for ' |
437 |
441 |
'Content-Length') |
438 |
442 |
|
439 |
if 'Content-Type' not in |
|
443 |
if 'Content-Type' not in _headers: |
|
440 |
444 |
type_ = None |
441 |
445 |
if hasattr(body, 'name'): |
442 |
446 |
type_ = mimetypes.guess_type(body.name)[0] |
