阅读背景:

在Django中使用嵌套的@ transaction.commit_on_success

来源:互联网 

Consider this simple example :

考虑这个简单的例子:

# a bank account class
class Account:
    @transaction.commit_on_success
    def withdraw(self, amount):
        # code to withdraw money from the account 

    @transaction.commit_on_success
    def add(self, amount):
        # code to add money to the account

# somewhere else
@transaction.commit_on_success
def makeMoneyTransaction(src_account, dst_account, amount):
    src_account.withdraw(amount)
    dst_account.add(amount)
#



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: