Skip to content
Browse files

update doc & news

  • Loading branch information...
1 parent a2a63a0 commit 3f978d516ec030f112d92ac7593659254fdf7847 benoitc committed
Showing with 55 additions and 35 deletions.
  1. +21 −0 doc/news.rst
  2. +16 −16 doc/pool.rst
  3. +3 −5 doc/resource.rst
  4. +7 −6 doc/wsgi_proxy.rst
  5. +8 −8 restkit/client/request.py
View
21 doc/news.rst
@@ -3,6 +3,27 @@
News
====
+2.3.0 / 2010-11-25
+------------------
+ - Refactored Http Connections management (reuse connections).
+ restkit.pool is now replaced by restkit.conn module. SimplePool has
+ been replaced by TConnectionManager (threadsafe). Now by default all
+ connections are reusing connections using TConnectionManager (10
+ connections per route).
+ - Improved Gevent & Eventlet support
+ - Added an ``decompress`` option to ``request`` function and ``Resource``
+ instance to decompress the body or not. By default it's true.
+ - Added ``params_dict`` to keywords arguments of ``Resource`` instances
+ methods. Allows you to pass any argument to the query.
+ - Fix response 100-continue
+ - Fix compressed atatchments
+ - Fix body readline
+ - Fix basic authentication
+ - Stop when system exit or keyboard interrupt
+ - Fix oauth2
+
+More details `here <https://github.com/benoitc/restkit/compare/2.1.1...2.1.3>`_ .
+
2.2.1 / 2010-09-18
------------------
- Fix readline `b7365155 <http://github.com/benoitc/restkit/commit/b7365155168cc9df7e48edabad79b2c478e8c5c7>`_ .
View
32 doc/pool.rst
@@ -1,33 +1,33 @@
Reuses connections
==================
-Reusing connections is good. Restkit can maintain for you the http connections and reuse them if the server allows it. To do that you can pass to any object a pool instance inheriting :api:`reskit.pool.PoolInterface`. You can use our threadsafe pool in any application::
+Reusing connections is good. Restkit can maintain for you the http connections and reuse them if the server allows it. To do that you can pass to any object a connection manager instance inheriting :api:`reskit.conn.base.ConnManager`. You can use our threadsafe pool in any application::
- from restkit import Resource, SimplePool
+ from restkit import Resource, TConnectionManager
- pool = SimplePool(keepalive=2)
- res = Resource('http://friendpaste.com', pool_instance=pool)
+ manager = TConnectionManager(nb_connections=10)
+ res = Resource('http://friendpaste.com', conn_manager=manager)
+
+.. NOTE::
+
+ By default, restkit is using the threadsafe connections manager
+ and keep 10 connections alive.
Restkit provides also Pool working with `eventlet <http://eventlet.net>`_ or `gevent <http://gevent.net>`_.
Example of usage with Gevent::
- from restkit import *
- from gevent import monkey; monkey.patch_socket()
- from restkit.pool.rgevent import GeventPool
- pool = GeventPool(keepalive=2, timeout=300)
- r = request('http://friendpaste.com', pool_instance=pool)
+ from restkit import request
+ from restkit.conn.gevent_manager import GeventConnectionManager
+ manager = GeventConnectionManager(timeout=300, nb_connections=10)
+ r = request('http://friendpaste.com', conn_manager=manager)
This is likely the same with Eventlet::
- import eventlet
- eventlet.monkey_patch(all=False, socket=True, select=True)
-
from restkit import Resource
- from restkit.pool.reventlet import EventletPool
+ from restkit.conn.eventlet_manager import EventletConnectionManager
- pool = EventletPool(keepalive=2, timeout=300)
- res = Resource('http://friendpaste.com', pool_instance=pool)
+ manager = EventletConnectionManager(timeout=300, nb_connections=300)
+ res = Resource('http://friendpaste.com', conn_manager=manager)
-Using `Eventlet` or `Gevent` pools is definitely better since it allows you to define a timeout for connections. When timeout is reached and the connection is still in the pool, it will be closed.
View
8 doc/resource.rst
@@ -19,19 +19,17 @@ Here is the snippet::
class TwitterSearch(Resource):
- def __init__(self, pool_instance=None, **kwargs):
+ def __init__(self, **kwargs):
search_url = "http://search.twitter.com"
super(TwitterSearch, self).__init__(search_url, follow_redirect=True,
- max_follow_redirect=10,
- pool_instance=pool_instance,
- **kwargs)
+ max_follow_redirect=10, **kwargs)
def search(self, query):
return self.get('search.json', q=query)
def request(self, *args, **kwargs):
resp = super(TwitterSearch, self).request(*args, **kwargs)
- return json.loads(resp.body)
+ return json.loads(resp.body_string())
if __name__ == "__main__":
s = TwitterSearch()
View
13 doc/wsgi_proxy.rst
@@ -16,11 +16,11 @@ use `webob <http://pythonpaste.org/webob/>`_ and `gunicorn
import urlparse
from webob import Request
- from restkit.pool.simple import SimplePool
+ from restkit.conn import TConnectionManager
from restkit.ext.wsgi_proxy import HostProxy
- pool = SimplePool(keepalive=10)
- proxy = HostProxy("http://127.0.0.1:5984", pool=pool)
+ mgr = TConnectionManager(nb_connections=10)
+ proxy = HostProxy("http://127.0.0.1:5984", pool=mgr)
def application(environ, start_response):
@@ -59,11 +59,12 @@ distributed proxy. `/a/db` will proxify `http://a.mypool.org/db`::
import urlparse
from webob import Request
- from restkit.pool.simple import SimplePool
+ from restkit.conn import TConnectionManager
from restkit.ext.wsgi_proxy import Proxy
- pool = SimplePool(keepalive=10)
- proxy = Proxy(pool=pool, strip_script_name=True)
+ mgr = TConnectionManager(nb_connections=10)
+
+ proxy = Proxy(pool=mgr, strip_script_name=True)
def application(environ, start_response):
View
16 restkit/client/request.py
@@ -50,7 +50,7 @@ def __init__(self,
decompress=True,
pool_instance=None,
response_class=None,
- connection_manager=None,
+ conn_manager=None,
**ssl_args):
""" HttpRequest constructor
@@ -63,8 +63,8 @@ def __init__(self,
the location.
:param max_follow_redirect: max number of redirection. If max is reached
the RedirectLimit exception is raised.
- :param pool_instance: a pool instance inherited from
- `restkit.pool.PoolInterface`
+ :param conn_manager: a connectoin manager instance inherited from
+ `restkit.conn.base.ConnectioManager`
:param ssl_args: ssl arguments. See http://docs.python.org/library/ssl.html
for more information.
"""
@@ -89,11 +89,11 @@ def __init__(self,
self.ssl_args = ssl_args or {}
if pool_instance is not None:
- self.connection_manager = pool_instance
- elif connection_manager is not None:
- self.connection_manager = connection_manager
+ self.conn_manager = pool_instance
+ elif conn_manager is not None:
+ self.conn_manager = conn_manager
else:
- self.connection_manager = get_default_manager()
+ self.conn_manager = get_default_manager()
if response_class is not None:
self.response_class = response_class
@@ -268,7 +268,7 @@ def do_send(self):
addr = (self.host, self.port)
is_ssl = (self.uri.scheme == "https")
route = (addr, is_ssl, self.filters, self.ssl_args)
- self._pool = self.connection_manager.get_pool(route)
+ self._pool = self.conn_manager.get_pool(route)
tries = 2
while True:
try:

0 comments on commit 3f978d5

Please sign in to comment.
Something went wrong with that request. Please try again.