Browse files

Make possible to choose if to abort the transaction manager or just r…

…ollback the session
  • Loading branch information...
1 parent 1eca9ae commit 42d25e2ac0b41ea33401c8c870d129e820ae932a @amol- amol- committed Nov 13, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 tgext/crud/
@@ -2,7 +2,7 @@
from decorator import decorator
from tg.decorators import validate as tgValidate
-from tg import flash
+from tg import flash, config
import transaction
class registered_validate(tgValidate):
@@ -106,7 +106,11 @@ def wrapper(func, self, *args, **kwargs):
if isinstance(e, sqla_errors):
#if the error is a sqlalchemy error suppose we need to rollback the transaction
#so that the error handler can perform queries.
- transaction.abort()
+ if config.get('tgext.crud.abort_transactions', False):
+ #This is in case we need to support multiple databases or two phase commit.
+ transaction.abort()
+ else:
+ self.session.rollback()
return self._call(func, params=kwargs, remainder=remainder)

1 comment on commit 42d25e2


moschlar commented on 42d25e2 Nov 13, 2012

Great, thank you!

Please sign in to comment.