forked from jmoiron/johnny-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates a compatibility layer for transaction.[is_]managed
- Loading branch information
1 parent
72a6dfd
commit a2a353c
Showing
3 changed files
with
67 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
Tools to ease compatibility across supported versions of Django & Python. | ||
""" | ||
|
||
from __future__ import unicode_literals | ||
import django | ||
from django.db import transaction | ||
|
||
|
||
def is_managed(using=None): | ||
if django.VERSION[:2] < (1, 6): | ||
return transaction.is_managed(using=using) | ||
return False | ||
# Or maybe we should run the following line? I'm not sure… | ||
# return not transaction.get_autocommit(using=using) | ||
|
||
|
||
def managed(flag=True, using=None): | ||
if django.VERSION[:2] < (1, 6): | ||
transaction.managed(flag=flag, using=using) | ||
# Maybe we should execute the following line otherwise? I'm not sure… | ||
# transaction.set_autocommit(autocommit=not flag, using=using) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters