Re: how to handle sqlalchemy exception with pyramid?
The real exceptions occur when the data is flushed to the database, not the actual commit. If you do a dbsession.flush() in your view code and it doesn't error then you can be fairly certain that the transaction's commit() will not fail. -- Michael -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
ReĀ : how to handle sqlalchemy exception with pyramid?
Sorry my first message was incomplete (accidental sending): I solved my problem with the use of a finished callback: def commit_callback(request): '''commit or abort the transaction associated with request''' if request.exception is not None: transaction.abort() else: try: transaction.commit() except exc.SQLAlchemyError as e: print e transaction.abort() Is it the right way for handling sqlalchemy exception in a callable view? Thanks. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/9SQvs9wkQS8J. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.