manda
manda

Reputation: 228

how to put in transaction

I have a class:

class AccountTransaction(db.Model):
    account = db.ReferenceProperty(reference_class=Account)
    tran_date = db.DateProperty()
    debit_credit = db.IntegerProperty() ## -1, 1
    amount = db.FloatProperty()
    comment = db.StringProperty()
    pair = db.SelfReferenceProperty()

so, what I want is to make a Save() method which would run the following steps in the transaction:

It is possible that the parents of transactions be the their Accounts, but yet it seems impossible to make an entity group of these entities.

Described in terms of RDBMS, this means that I want that one table has two foreign keys (one entity - two parents). What to do?

At first, I tried not to manage the balances, but it seems to slow to calculate it every time ...

What to do?

Upvotes: 1

Views: 123

Answers (1)

Nick Johnson
Nick Johnson

Reputation: 101139

Because your Account entities can't all be in the same entity group, you can't perform an update in a single transaction. There are techniques to do this, particularly in the 'money transfer' case you've encountered - I wrote a blog post about this exact subject, in fact.

Upvotes: 1

Related Questions