Permalink
Browse files

Updated documentation.

  • Loading branch information...
1 parent eb478fc commit d46d6e4cec63e457d54b34fae663ab27086dae50 @FSX committed Jul 30, 2012
Showing with 39 additions and 101 deletions.
  1. +2 −1 ChangeLog
  2. +8 −17 docs/api.rst
  3. +0 −64 docs/examples.rst
  4. +2 −2 docs/index.rst
  5. +3 −1 docs/news.rst
  6. +12 −8 momoko/clients.py
  7. +6 −4 momoko/pools.py
  8. +6 −4 momoko/utils.py
View
@@ -1,9 +1,10 @@
News/Changelog
==============
-0.5.1 (2012-07-??)
+0.5.0 (2012-07-30)
------------------
+* Removed all Adisp related code.
* Refactored connection pool and connection polling.
* Just pass all unspecified arguments to ``BlockingPool`` and ``AsyncPool``. So
``connection_factory`` can be used again.
View
@@ -25,15 +25,6 @@ AsyncClient Object
:inherited-members:
-AdispClient Object
-------------------
-
-.. autoclass:: momoko.AdispClient
- :members:
- :inherited-members:
- :undoc-members:
-
-
BlockingPool Object
-------------------
@@ -50,25 +41,25 @@ AsyncPool Object
:inherited-members:
-QueryChain Object
------------------
+AsyncConnection Object
+----------------------
-.. autoclass:: momoko.utils.QueryChain
+.. autoclass:: momoko.pools.AsyncConnection
:members:
:inherited-members:
-BatchQuery Object
+QueryChain Object
-----------------
-.. autoclass:: momoko.utils.BatchQuery
+.. autoclass:: momoko.utils.QueryChain
:members:
:inherited-members:
-Poller Object
--------------
+BatchQuery Object
+-----------------
-.. autoclass:: momoko.utils.Poller
+.. autoclass:: momoko.utils.BatchQuery
:members:
:inherited-members:
View
@@ -112,70 +112,6 @@ The asynchronous client that uses callbacks::
self.finish()
-Adisp
------
-
-The asynchronous client that uses ``adisp`` (included in Momoko)::
-
- class BaseHandler(tornado.web.RequestHandler):
- @property
- def db(self):
- # Create a database connection when a request handler is called
- # and store the connection in the application object.
- if not hasattr(self.application, 'db'):
- self.application.db = momoko.AdispClient({
- 'host': 'localhost',
- 'database': 'momoko',
- 'user': 'frank',
- 'password': '',
- 'min_conn': 1,
- 'max_conn': 20,
- 'cleanup_timeout': 10
- })
- return self.application.db
-
-
- class SingleQueryHandler(BaseHandler):
- @tornado.web.asynchronous
- @momoko.process
- def get(self):
- # One simple query
- cursor = yield self.db.execute('SELECT 42, 12, 40, 11;')
- self.write('Query results: %s' % cursor.fetchall())
- self.finish()
-
-
- class BatchQueryHandler(BaseHandler):
- @tornado.web.asynchronous
- @momoko.process
- def get(self):
- # These queries are executed all at once and therefore they need to be
- # stored in an dictionary so you know where the resulting cursors
- # come from, because they won't arrive in the same order.
- cursors = yield self.db.batch({
- 'query1': ['SELECT 42, 12, %s, %s;', (23, 56)],
- 'query2': 'SELECT 1, 2, 3, 4, 5;',
- 'query3': 'SELECT 465767, 4567, 3454;'
- })
- for key, cursor in cursors.items():
- self.write('Query results: %s = %s<br>' % (key, cursor.fetchall()))
- self.finish()
-
-
- class QueryChainHandler(BaseHandler):
- @tornado.web.asynchronous
- @momoko.process
- def get(self):
- # Execute a list of queries in the order you specified
- cursors = yield self.db.chain((
- ['SELECT 42, 12, %s, 11;', (23,)],
- 'SELECT 1, 2, 3, 4, 5;'
- ))
- for cursor in cursors:
- self.write('Query results: %s<br>' % cursor.fetchall())
- self.finish()
-
-
Tornado's gen
-------------
View
@@ -5,8 +5,8 @@ Momoko
An asynchronous Psycopg2_ wrapper for Tornado_.
-Momoko makes use of the asynchronous support in Psycopg2, Tornado's IOLoop and
-**adisp** to provide asynchronous queries in callback and blocking style.
+Momoko makes use of the asynchronous support in Psycopg2, Tornado's IOLoop
+to provide asynchronous queries in callback and blocking style.
Downloads can be found at PyPi_ and the lastest source code at Github_.
.. _Tornado: http://www.tornadoweb.org/
View
@@ -4,9 +4,11 @@ News/Changelog
==============
-0.4.1 (2012-01-??)
+0.5.0 (2012-07-30)
------------------
+* Removed all Adisp related code.
+* Refactored connection pool and connection polling.
* Just pass all unspecified arguments to ``BlockingPool`` and ``AsyncPool``. So
``connection_factory`` can be used again.
View
@@ -79,10 +79,11 @@ def batch(self, queries, callback=None, cursor_kwargs={}):
:param queries: A dictionary with all the queries.
:param callback: The function that needs to be executed once all the
queries are finished. Optional.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
:return: A dictionary with the same keys as the given queries with the
resulting cursors as values.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
return BatchQuery(self, queries, callback)
@@ -103,9 +104,10 @@ def chain(self, queries, callback=None, cursor_kwargs={}):
:param queries: A tuple or list with all the queries.
:param callback: The function that needs to be executed once all the
queries are finished. Optional.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
:return: A list with the resulting cursors.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
return QueryChain(self, queries, callback)
@@ -124,8 +126,9 @@ def execute(self, operation, parameters=(), callback=None, cursor_kwargs={}):
an empty tuple by default.
:param callback: A callable that is executed once the operation is
finished. Optional.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
self._pool.new_cursor('execute', (operation, parameters), callback, cursor_kwargs)
@@ -144,8 +147,9 @@ def callproc(self, procname, parameters=None, callback=None, cursor_kwargs={}):
:param parameters: A sequence with parameters. This is ``None`` by default.
:param callback: A callable that is executed once the procedure is
finished. Optional.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
self._pool.new_cursor('callproc', (procname, parameters), callback, cursor_kwargs)
View
@@ -194,9 +194,10 @@ def new_cursor(self, function, function_args=(), callback=None, cursor_kwargs={}
:param function: ``execute``, ``executemany`` or ``callproc``.
:param function_args: A tuple with the arguments for the specified function.
:param callback: A callable that is executed once the operation is done.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
:param connection: An ``AsyncConnection`` connection. Optional.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
if connection is None:
connection = self._get_free_conn()
@@ -297,8 +298,9 @@ def cursor(self, function, function_args, callback, cursor_kwargs={}):
:param function: ``execute``, ``executemany`` or ``callproc``.
:param function_args: A tuple with the arguments for the specified function.
:param callback: A callable that is executed once the operation is done.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
cursor = self._conn.cursor(**cursor_kwargs)
getattr(cursor, function)(*function_args)
View
@@ -35,9 +35,10 @@ class QueryChain(object):
:param queries: A tuple or with all the queries.
:param callback: The function that needs to be executed once all the
queries are finished.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
:return: A list with the resulting cursors is passed on to the callback.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
def __init__(self, db, queries, callback, cursor_kwargs={}):
self._db = db
@@ -84,10 +85,11 @@ class BatchQuery(object):
:param queries: A dictionary with all the queries.
:param callback: The function that needs to be executed once all the
queries are finished.
- :param cursor_kwargs: A dictionary with Psycopg's
- `connection.cursor<http://initd.org/psycopg/docs/connection.html#connection.cursor>`_ arguments.
+ :param cursor_kwargs: A dictionary with Psycopg's `connection.cursor`_ arguments.
:return: A dictionary with the same keys as the given queries with the
resulting cursors as values is passed on to the callback.
+
+ .. _connection.cursor: http://initd.org/psycopg/docs/connection.html#connection.cursor
"""
def __init__(self, db, queries, callback, cursor_kwargs={}):
self._db = db

0 comments on commit d46d6e4

Please sign in to comment.