Added name parameters to .cursor() calls in extras.

This commit is contained in:
Federico Di Gregorio 2007-09-01 09:32:42 +00:00
parent dfda372fae
commit 0422506404
2 changed files with 25 additions and 9 deletions

View File

@ -1,3 +1,7 @@
2007-09-01 Federico Di Gregorio <fog@initd.org>
* Added "name" parameter to all .cursor() calls in extras.py.
2007-05-29 Federico Di Gregorio <fog@initd.org>
* Release 2.0.6.

View File

@ -69,8 +69,11 @@ class DictCursorBase(_cursor):
class DictConnection(_connection):
"""A connection that uses DictCursor automatically."""
def cursor(self):
return _connection.cursor(self, cursor_factory=DictCursor)
def cursor(self, name=None):
if name is None:
return _connection.cursor(self, cursor_factory=DictCursor)
else:
return _connection.cursor(self, name, cursor_factory=DictCursor)
class DictCursor(DictCursorBase):
"""A cursor that keeps a list of column name -> index mappings."""
@ -135,8 +138,11 @@ class DictRow(list):
class RealDictConnection(_connection):
"""A connection that uses RealDictCursor automatically."""
def cursor(self):
return _connection.cursor(self, cursor_factory=RealDictCursor)
def cursor(self, name=None):
if name is None:
return _connection.cursor(self, cursor_factory=RealDictCursor)
else:
return _connection.cursor(self, name, cursor_factory=RealDictCursor)
class RealDictCursor(DictCursorBase):
"""A cursor that uses a real dict as the base type for rows.
@ -215,10 +221,13 @@ class LoggingConnection(_connection):
raise self.ProgrammingError(
"LoggingConnection object has not been initialize()d")
def cursor(self):
def cursor(self, name=None):
self._check()
return _connection.cursor(self, cursor_factory=LoggingCursor)
if name is None:
return _connection.cursor(self, cursor_factory=LoggingCursor)
else:
return _connection.cursor(self, name, cursor_factory=LoggingCursor)
class LoggingCursor(_cursor):
"""A cursor that logs queries using its connection logging facilities."""
@ -254,9 +263,12 @@ class MinTimeLoggingConnection(LoggingConnection):
if t > self._mintime:
return msg + os.linesep + " (execution time: %d ms)" % t
def cursor(self):
def cursor(self, name=None):
self._check()
return _connection.cursor(self, cursor_factory=MinTimeLoggingCursor)
if name is None:
return _connection.cursor(self, cursor_factory=MinTimeLoggingCursor)
else:
return _connection.cursor(self, name, cursor_factory=MinTimeLoggingCursor)
class MinTimeLoggingCursor(LoggingCursor):
"""The cursor sub-class companion to MinTimeLoggingConnection."""