O'Reilly logo

Mastering Google App Engine by Mohsin Shafique Hijazee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transactions

There are cases where you'd want a number of operations to succeed or fail altogether and nothing in between. This is called a transaction, and App Engine's datastore offers support for transactions. In App Engine, you do this by encapsulating all the steps that you want to fail or succeed together in a function and decorate it with the ndb.transactional decorator.

Let's suppose that it so happens that we add a new property called city to indicate the city that the car is in. Sometimes, two cars are exchanged between two dealers in two difference cities. In that case, we need to update the cities of these two listings and basically swap them. There are multiple datastore operations involved here, given that we have keys for both the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required