GithubHelp home page GithubHelp logo

Comments (7)

jimfulton avatar jimfulton commented on June 3, 2024

I'm wondering what the use cases for this are. I have never wanted to interrogate any of this.

from transaction.

icemac avatar icemac commented on June 3, 2024

@jimfulton I have a Pyramid application with a PostgreSQL backend. After an INSERT I am using transaction.savepoint() to make sure that an IntegrityError is raised immediately. (Otherwise it would occur on the next implicit flush which does not help at all.)
transaction.savepoint() sets the status of the transaction to COMMITFAILED if there was an error.

I catch the IntegrityError and return (not raise!) a custom exception which the front end can handle and display.

pyramid_tm does not check for the status of the transaction but does a transaction.commit() which leads to a long and nested error message which cannot be displayed to the user. But it supports calling a function which can veto the commit (e. g. for 4xx and 5xx status codes.)
Thus I ended writing such a veto function which checks whether the status of the transaction is transaction._transaction.Status.COMMITFAILED to force pyramind_tm to abort the transaction.

Wow, this is complicated.

TL;DR: If the transaction in the status COMMITFAILED (which was set by a failed savepoint) I do not want to commit it at the end of the request as this would fail, too. I have to check the status and then abort it if needed.

from transaction.

jinty avatar jinty commented on June 3, 2024

from transaction.

jimfulton avatar jimfulton commented on June 3, 2024

from transaction.

jimfulton avatar jimfulton commented on June 3, 2024

from transaction.

icemac avatar icemac commented on June 3, 2024

from transaction.

icemac avatar icemac commented on June 3, 2024

Closing as suggested by myself.

from transaction.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.