Work towards #16 -- Use psycopg2cffi compatibility if psycopg2 not installed.

This commit is contained in:
Tyson Clugg 2015-10-08 11:58:42 +11:00
parent 73465d6ed4
commit 397e044ddd

View file

@ -6,7 +6,6 @@ from pkg_resources import get_distribution, DistributionNotFound
from gevent.local import local
from dddp import alea
try:
_dist = get_distribution('django-ddp')
if not __file__.startswith(os.path.join(_dist.location, 'django-ddp', '')):
@ -43,6 +42,14 @@ def greenify():
# ensure we don't greenify again
_GREEN[True] = True
try:
# Use psycopg2 by default
import psycopg2
except ImportError:
# Fallback to psycopg2cffi if required (eg: pypy)
from psycopg2cffi import compat
compat.register()
class AlreadyRegistered(Exception):