django深入----django.db.transaction

django 的事务:

 

transaction.py

atomic---原子性
def atomic(using=None, savepoint=True):
    # Bare decorator: @atomic -- although the first argument is called
    # `using`, it's actually the function being decorated.
    if callable(using):
        return Atomic(DEFAULT_DB_ALIAS, savepoint)(using)
    # Decorator: @atomic(...) or context manager: with atomic(...): ...
    else:
        return Atomic(using, savepoint)

调用:

 

    @tx.atomic
    @model_pk_lock
    def update(self, request, *args, **kwargs):

 

posted @ 2017-03-27 21:03  八月的男人  阅读(307)  评论(0编辑  收藏  举报