summaryrefslogtreecommitdiff
path: root/openerp/sql_db.py
diff options
context:
space:
mode:
authorP. Christeas <xrg@openerp.com>2011-07-02 01:19:56 +0200
committerOlivier Dony <odo@openerp.com>2011-07-02 01:19:56 +0200
commit7c8665bb694bc5d7e762c77ab59f05922b511e2a (patch)
tree51ac1a15cc6e5730346ab96a6ce6ec340998a07e /openerp/sql_db.py
parente093396b4aee5abe6f282f59ab93ae8f66739a44 (diff)
parentbec65af2681dd4bdb021af20610e38d919ed7269 (diff)
[MERGE] docstrings improvements and preparation for api-doc structure
bzr revid: odo@openerp.com-20110701231956-93zu7xtibpo06eqm
Diffstat (limited to 'openerp/sql_db.py')
-rw-r--r--openerp/sql_db.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/openerp/sql_db.py b/openerp/sql_db.py
index e759a13e1d3..43a508f9082 100644
--- a/openerp/sql_db.py
+++ b/openerp/sql_db.py
@@ -20,6 +20,19 @@
#
##############################################################################
+#.apidoc title: PostgreSQL interface
+
+"""
+The PostgreSQL connector is a connectivity layer between the OpenERP code and
+the database, *not* a database abstraction toolkit. Database abstraction is what
+the ORM does, in fact.
+
+See also: the `pooler` module
+"""
+
+#.apidoc add-functions: print_stats
+#.apidoc add-classes: Cursor Connection ConnectionPool
+
__all__ = ['db_connect', 'close_db']
from threading import currentThread
@@ -66,6 +79,13 @@ re_into = re.compile('.* into "?([a-zA-Z_0-9]+)"? .*$');
sql_counter = 0
class Cursor(object):
+ """ Cursor is an open transaction to Postgres, utilizing a TCP connection
+
+ A lightweight wrapper around psycopg2's `psycopg1cursor` objects
+
+ This is the object behind the `cr` variable used all over the OpenERP
+ code.
+ """
IN_MAX = 1000 # decent limit on size of IN queries - guideline = Oracle limit
__logger = None
@@ -233,22 +253,37 @@ class Cursor(object):
@check
def commit(self):
+ """ Perform an SQL `COMMIT`
+ """
return self._cnx.commit()
@check
def rollback(self):
+ """ Perform an SQL `ROLLBACK`
+ """
return self._cnx.rollback()
@check
def __getattr__(self, name):
return getattr(self._obj, name)
+ """ Set the mode of postgres operations for all cursors
+ """
+ """Obtain the mode of postgres operations for all cursors
+ """
class PsycoConnection(psycopg2.extensions.connection):
pass
class ConnectionPool(object):
-
+ """ The pool of connections to database(s)
+
+ Keep a set of connections to pg databases open, and reuse them
+ to open cursors for all transactions.
+
+ The connections are *not* automatically closed. Only a close_db()
+ can trigger that.
+ """
__logger = logging.getLogger('db.connection_pool')
def locked(fun):
@@ -340,6 +375,8 @@ class ConnectionPool(object):
class Connection(object):
+ """ A lightweight instance of a connection to postgres
+ """
__logger = logging.getLogger('db.connection')
def __init__(self, pool, dbname):