Skip to content

Commit

Permalink
Merge pull request #37 from 4teamwork/merge-postgres-extra
Browse files Browse the repository at this point in the history
Move postgres depdendency to extra
  • Loading branch information
Denis Krienbühl committed Oct 28, 2013
2 parents 7655f3a + 9c23d88 commit d7bf397
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 12 additions & 4 deletions seantis/reservation/error.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from sqlalchemy.exc import IntegrityError
from psycopg2.extensions import TransactionRollbackError
from sqlalchemy.orm.exc import NoResultFound
import pkg_resources

from seantis.reservation import _

try:
pkg_resources.get_distribution('psycopg2')
from psycopg2.extensions import TransactionRollbackError
HAS_PSYCOPG2 = True
except pkg_resources.DistributionNotFound:
HAS_PSYCOPG2 = False


class ReservationError(Exception):
pass
Expand Down Expand Up @@ -96,9 +103,6 @@ class InvalidAllocationError(ReservationError):
AffectedPendingReservationError:
_(u'A pending reservation would be affected by the requested change'),

TransactionRollbackError:
_(u'The resource is being edited by someone else. Please try again.'),

NoResultFound:
_(u'The item does no longer exist.'),

Expand Down Expand Up @@ -142,3 +146,7 @@ class InvalidAllocationError(ReservationError):
_(u'The resulting allocation would be invalid'),

}

if HAS_PSYCOPG2:
errormap[TransactionRollbackError] = _(u'The resource is being edited by '
'someone else. Please try again.')
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
'plone.app.multilingual [dexterity]',
]

postgres_require = [
'psycopg2',
]


def get_long_description():
readme = open('README.rst').read()
Expand Down Expand Up @@ -75,7 +79,6 @@ def get_long_description():
'plone.uuid>=1.0.2',
'Plone>=4.3',
'profilehooks',
'psycopg2',
'pytz',
'setuptools',
'SQLAlchemy>=0.7.3',
Expand All @@ -86,7 +89,9 @@ def get_long_description():
extras_require=dict(zug=zug_require,
tests=tests_require,
multilingual=multilingual_require,
teamraum=teamraum_require),
postgres=postgres_require,
teamraum=teamraum_require
),
entry_points="""
# -*- Entry points: -*-
Expand Down

0 comments on commit d7bf397

Please sign in to comment.