[postgres] Add an adapter for the psycopg2cffi driver, which works great with pypy

Closes #235433

authorChristophe de Vienne <cdevienne@gmail.com>
changesetc0b344ec946e
branchdefault
phasepublic
hiddenno
parent revision#0a8db937ad7b [postgres] remove support for non-psycopg2 drivers
child revision#7e9fc3d08dab [psycopg] pass extra_args down to connect(), #105c7dd5a66f [pkg] Prepare 1.13.0
files modified by this revision
postgres.py
# HG changeset patch
# User Christophe de Vienne <cdevienne@gmail.com>
# Date 1382634427 -7200
# Thu Oct 24 19:07:07 2013 +0200
# Node ID c0b344ec946e9b02445468bc80d40de383df6f08
# Parent 0a8db937ad7b33c922fc380d9fdb286fd05d0761
[postgres] Add an adapter for the psycopg2cffi driver, which works great with pypy

Closes #235433

diff --git a/postgres.py b/postgres.py
@@ -122,18 +122,30 @@
1          # install psycopg2 compatibility
2          from psycopg2ct import compat
3          compat.register()
4          _Psycopg2Adapter.__init__(self, native_module, pywrap)
5 
6 +class _Psycopg2CffiAdapter(_Psycopg2Adapter):
7 +    """psycopg2cffi adapter
8 +
9 +    cf. https://pypi.python.org/pypi/psycopg2cffi
10 +    """
11 +    def __init__(self, native_module, pywrap=False):
12 +        # install psycopg2 compatibility
13 +        from psycopg2cffi import compat
14 +        compat.register()
15 +        _Psycopg2Adapter.__init__(self, native_module, pywrap)
16 +
17 
18  db._PREFERED_DRIVERS['postgres'] = [
19      #'logilab.database._pyodbcwrap',
20 -    'psycopg2', 'psycopg2ct',
21 +    'psycopg2', 'psycopg2ct', 'psycopg2cffi',
22      ]
23  db._ADAPTER_DIRECTORY['postgres'] = {
24      'psycopg2' : _Psycopg2Adapter,
25      'psycopg2ct' : _Psycopg2CtypesAdapter,
26 +    'psycopg2cffi' : _Psycopg2CffiAdapter,
27      }
28 
29 
30  class _PGAdvFuncHelper(db._GenericAdvFuncHelper):
31      """Postgres helper, taking advantage of postgres SEQUENCE support