Skip to content

Commit 1f57f22

Browse files
committed
Require Python 2.6 and start fully supporting Python 3
1 parent cc67cdc commit 1f57f22

28 files changed

+523
-592
lines changed

DBUtils/Docs/UsersGuide.de.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ <h1 class="title">Benutzeranleitung für DBUtils</h1>
1212

1313
<dl class="docinfo simple">
1414
<dt class="version">Version</dt>
15-
<dd class="version">1.1.1</dd>
15+
<dd class="version">1.2</dd>
1616
<dt class="released">Released</dt>
17-
<dd class="released"><p>02/04/17</p>
17+
<dd class="released"><p>02/05/17</p>
1818
</dd>
1919
<dt class="translations">Translations</dt>
2020
<dd class="translations"><p><a class="reference external" href="UsersGuide.html">English</a> | German</p>
@@ -159,11 +159,10 @@ <h2>Installation als Unterpaket (Plug-In) von Webware for Python</h2>
159159
</div>
160160
<div class="section" id="anforderungen">
161161
<h1>Anforderungen</h1>
162-
<p>DBUtils arbeitet mit <a class="reference external" href="https://www.python.org">Python</a> 2.3 oder einer neueren Version von Python 2.
163-
Die Module in der Variante für klassisches PyGreSQL benötigen <a class="reference external" href="http://www.pygresql.org/">PyGreSQL</a>
164-
Version 3.4 oder höher, während die Module in der allgemeinen Variante
165-
für DB-API 2 mit jedem beliebigen Python-Datenbankadapter-Modul
166-
zusammenarbeiten, das auf <a class="reference external" href="https://www.python.org/dev/peps/pep-0249/">DB-API 2</a> basiert.</p>
162+
<p>DBUtils benötigt mindestens <a class="reference external" href="https://www.python.org">Python</a> Version 2.6. Die Module in der Variante
163+
für klassisches PyGreSQL benötigen <a class="reference external" href="http://www.pygresql.org/">PyGreSQL</a> Version 3.4 oder höher, während
164+
die Module in der allgemeinen Variante für DB-API 2 mit jedem beliebigen
165+
Python-Datenbankadapter-Modul zusammenarbeiten, das auf <a class="reference external" href="https://www.python.org/dev/peps/pep-0249/">DB-API 2</a> basiert.</p>
167166
</div>
168167
<div class="section" id="funktionalitat">
169168
<h1>Funktionalität</h1>

DBUtils/Docs/UsersGuide.de.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Benutzeranleitung für DBUtils
22
+++++++++++++++++++++++++++++
33

4-
:Version: 1.1.1
5-
:Released: 02/04/17
4+
:Version: 1.2
5+
:Released: 02/05/17
66
:Translations: English_ | German
77

88
.. _English: UsersGuide.html
@@ -111,11 +111,10 @@ wenn Sie DBUtils in die Webware-Dokumentation integrieren wollen::
111111
Anforderungen
112112
=============
113113

114-
DBUtils arbeitet mit Python_ 2.3 oder einer neueren Version von Python 2.
115-
Die Module in der Variante für klassisches PyGreSQL benötigen PyGreSQL_
116-
Version 3.4 oder höher, während die Module in der allgemeinen Variante
117-
für DB-API 2 mit jedem beliebigen Python-Datenbankadapter-Modul
118-
zusammenarbeiten, das auf `DB-API 2`_ basiert.
114+
DBUtils benötigt mindestens Python_ Version 2.6. Die Module in der Variante
115+
für klassisches PyGreSQL benötigen PyGreSQL_ Version 3.4 oder höher, während
116+
die Module in der allgemeinen Variante für DB-API 2 mit jedem beliebigen
117+
Python-Datenbankadapter-Modul zusammenarbeiten, das auf `DB-API 2`_ basiert.
119118

120119

121120
Funktionalität

DBUtils/Docs/UsersGuide.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ <h1 class="title">DBUtils User's Guide</h1>
1212

1313
<dl class="docinfo simple">
1414
<dt class="version">Version</dt>
15-
<dd class="version">1.1.1</dd>
15+
<dd class="version">1.2</dd>
1616
<dt class="released">Released</dt>
17-
<dd class="released"><p>02/04/17</p>
17+
<dd class="released"><p>02/05/17</p>
1818
</dd>
1919
<dt class="translations">Translations</dt>
2020
<dd class="translations"><p>English | <a class="reference external" href="UsersGuide.de.html">German</a></p>
@@ -158,10 +158,10 @@ <h2>Installation as a Webware for Python subpackage (plug-in)</h2>
158158
</div>
159159
<div class="section" id="requirements">
160160
<h1>Requirements</h1>
161-
<p>DBUtils runs with <a class="reference external" href="https://www.python.org">Python</a> 2.3 or newer Python 2 versions. The modules in
162-
the classic PyGreSQL variant need <a class="reference external" href="http://www.pygresql.org/">PyGreSQL</a> version 3.4 or above, while the
163-
modules in the universal DB-API 2 variant run with any Python <a class="reference external" href="https://www.python.org/dev/peps/pep-0249/">DB-API 2</a>
164-
compliant database interface module.</p>
161+
<p>DBUtils requires at least <a class="reference external" href="https://www.python.org">Python</a> version 2.6. The modules in the classic
162+
PyGreSQL variant need <a class="reference external" href="http://www.pygresql.org/">PyGreSQL</a> version 3.4 or above, while the modules
163+
in the universal DB-API 2 variant run with any Python <a class="reference external" href="https://www.python.org/dev/peps/pep-0249/">DB-API 2</a> compliant
164+
database interface module.</p>
165165
</div>
166166
<div class="section" id="functionality">
167167
<h1>Functionality</h1>

DBUtils/Docs/UsersGuide.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
DBUtils User's Guide
22
++++++++++++++++++++
33

4-
:Version: 1.1.1
5-
:Released: 02/04/17
4+
:Version: 1.2
5+
:Released: 02/05/17
66
:Translations: English | German_
77

88
.. _German: UsersGuide.de.html
@@ -110,10 +110,10 @@ integrate the DBUtils documentation into the Webware documentation::
110110
Requirements
111111
============
112112

113-
DBUtils runs with Python_ 2.3 or newer Python 2 versions. The modules in
114-
the classic PyGreSQL variant need PyGreSQL_ version 3.4 or above, while the
115-
modules in the universal DB-API 2 variant run with any Python `DB-API 2`_
116-
compliant database interface module.
113+
DBUtils requires at least Python_ version 2.6. The modules in the classic
114+
PyGreSQL variant need PyGreSQL_ version 3.4 or above, while the modules
115+
in the universal DB-API 2 variant run with any Python `DB-API 2`_ compliant
116+
database interface module.
117117

118118

119119
Functionality

DBUtils/PersistentDB.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
9696
Requirements:
9797
98-
Python >= 2.3, < 3.0.
98+
Python >= 2.6.
9999
100100
101101
Ideas for improvement:
@@ -116,15 +116,29 @@
116116
117117
"""
118118

119-
__version__ = '1.1.1'
120-
121-
import ThreadingLocal
122119
from DBUtils.SteadyDB import connect
123120

121+
__version__ = '1.2'
122+
123+
try:
124+
callable
125+
except NameError: # Python 3.0 or 3.1
126+
def callable(obj):
127+
return any('__call__' in cls.__dict__ for cls in type(obj).__mro__)
128+
try:
129+
# Prefer the pure Python version of threading.local.
130+
# The C implementation turned out to be problematic with mod_wsgi,
131+
# since it does not keep the thread-local data between requests.
132+
from _threading_local import local
133+
except ImportError:
134+
# Fall back to the default version of threading.local.
135+
from threading import local
136+
124137

125138
class PersistentDBError(Exception):
126139
"""General PersistentDB error."""
127140

141+
128142
class NotSupportedError(PersistentDBError):
129143
"""DB-API module not supported by PersistentDB."""
130144

@@ -186,12 +200,12 @@ def __init__(self, creator,
186200
self._ping = ping
187201
self._closeable = closeable
188202
self._args, self._kwargs = args, kwargs
189-
self.thread = (threadlocal or ThreadingLocal.local)()
203+
self.thread = (threadlocal or local)()
190204

191205
def steady_connection(self):
192206
"""Get a steady, non-persistent DB-API 2 connection."""
193-
return connect(self._creator,
194-
self._maxusage, self._setsession,
207+
return connect(
208+
self._creator, self._maxusage, self._setsession,
195209
self._failures, self._ping, self._closeable,
196210
*self._args, **self._kwargs)
197211

DBUtils/PersistentPg.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
8787
Requirements:
8888
89-
Python >= 2.3, < 3.0, PyGreSQL >= 3.4.
89+
Python >= 2.6, PyGreSQL >= 3.4.
9090
9191
9292
Ideas for improvement:
@@ -107,11 +107,18 @@
107107
108108
"""
109109

110-
__version__ = '1.1.1'
110+
from DBUtils.SteadyPg import SteadyPgConnection
111111

112+
__version__ = '1.2'
112113

113-
import ThreadingLocal
114-
from DBUtils.SteadyPg import SteadyPgConnection
114+
try:
115+
# Prefer the pure Python version of threading.local.
116+
# The C implementation turned out to be problematic with mod_wsgi,
117+
# since it does not keep the thread-local data between requests.
118+
from _threading_local import local
119+
except ImportError:
120+
# Fall back to the default version of threading.local.
121+
from threading import local
115122

116123

117124
class PersistentPg:
@@ -147,7 +154,7 @@ def __init__(self, maxusage=None, setsession=None,
147154
self._setsession = setsession
148155
self._closeable = closeable
149156
self._args, self._kwargs = args, kwargs
150-
self.thread = (threadlocal or ThreadingLocal.local)()
157+
self.thread = (threadlocal or local)()
151158

152159
def steady_connection(self):
153160
"""Get a steady, non-persistent PyGreSQL connection."""

DBUtils/PooledDB.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,31 @@
139139
140140
"""
141141

142-
__version__ = '1.1.1'
143-
144-
145142
from threading import Condition
146143

147144
from DBUtils.SteadyDB import connect
148145

146+
__version__ = '1.2'
147+
148+
try:
149+
callable
150+
except NameError: # Python 3.0 or 3.1
151+
def callable(obj):
152+
return any('__call__' in cls.__dict__ for cls in type(obj).__mro__)
153+
149154

150155
class PooledDBError(Exception):
151156
"""General PooledDB error."""
152157

158+
153159
class InvalidConnection(PooledDBError):
154160
"""Database connection is invalid."""
155161

162+
156163
class NotSupportedError(PooledDBError):
157164
"""DB-API module not supported by PooledDB."""
158165

166+
159167
class TooManyConnections(PooledDBError):
160168
"""Too many database connections were opened."""
161169

DBUtils/PooledPg.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,24 @@
108108
109109
"""
110110

111-
__version__ = '1.1.1'
112-
113111
try:
114112
from Queue import Queue, Empty, Full
115113
except ImportError: # Python 3
116114
from queue import Queue, Empty, Full
117115

118116
from DBUtils.SteadyPg import SteadyPgConnection
119117

118+
__version__ = '1.2'
119+
120120

121121
class PooledPgError(Exception):
122122
"""General PooledPg error."""
123123

124+
124125
class InvalidConnection(PooledPgError):
125126
"""Database connection is invalid."""
126127

128+
127129
class TooManyConnections(PooledPgError):
128130
"""Too many database connections were opened."""
129131

DBUtils/Properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name = 'DBUtils'
22

3-
version = (1, 1, 1)
3+
version = (1, 2, 0)
44

55
docs = [
66
{'name': "User's Guide", 'file': 'UsersGuide.html'},
77
]
88

99
status = 'beta'
1010

11-
requiredPyVersion = (2, 3, 0)
11+
requiredPyVersion = (2, 6, 0)
1212

1313
synopsis = """DBUtils provides database related support classes and functions to Webware. There is plenty of useful reusable code here."""
1414

DBUtils/SimplePooledDB.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@
7373
7474
"""
7575

76-
__version__ = '1.1.1'
76+
__version__ = '1.2'
77+
7778

7879
class PooledDBError(Exception):
7980
"""General PooledDB error."""
8081

82+
8183
class NotSupportedError(PooledDBError):
8284
"""DB-API module not supported by PooledDB."""
8385

0 commit comments

Comments
 (0)