Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c8257843
authored
Mar 01, 2014
by
Florian Apolloner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #201 from apollo13/atomic
Use Django's atomic when available.
parents
a0b63448
d6117ab9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
50 deletions
+30
-50
.travis.yml
+12
-28
taggit/models.py
+18
-4
tox.ini
+0
-18
No files found.
.travis.yml
View file @
c8257843
language
:
python
python
:
-
"
2.6"
-
"
2.7"
-
"
3.2"
-
"
3.3"
env
:
-
DJANGO=https://github.com/django/django/archive/master.tar.gz
-
DJANGO=django==1.6
-
DJANGO=django==1.5.5
-
DJANGO=django==1.4.10
-
TOXENV=py27-1.7.x
-
TOXENV=py33-1.5.x
-
TOXENV=py27-1.6.x
-
TOXENV=py33-1.6.x
-
TOXENV=py26-1.6.x
-
TOXENV=py27-1.5.x
-
TOXENV=py27-1.4.x
-
TOXENV=py33-1.7.x
-
TOXENV=py26-1.4.x
-
TOXENV=py26-1.5.x
install
:
-
pip install $DJANGO
-
pip install -r requirements/travis-ci.txt --use-mirrors
-
pip install tox
script
:
-
coverage run --source django_taggit runtests.py
-
coverage report
-
tox
notifications
:
email
:
false
matrix
:
exclude
:
-
python
:
"
3.2"
env
:
DJANGO=django==1.4.10
-
python
:
"
3.3"
env
:
DJANGO=django==1.4.10
-
python
:
"
2.6"
env
:
DJANGO=https://github.com/django/django/archive/master.tar.gz
taggit/models.py
View file @
c8257843
...
...
@@ -9,6 +9,23 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from
django.utils.encoding
import
python_2_unicode_compatible
try
:
atomic
=
transaction
.
atomic
except
AttributeError
:
from
contextlib
import
contextmanager
@contextmanager
def
atomic
(
using
=
None
):
sid
=
transaction
.
savepoint
(
using
=
using
)
try
:
yield
except
IntegrityError
:
transaction
.
savepoint_rollback
(
sid
,
using
=
using
)
raise
else
:
transaction
.
savepoint_commit
(
sid
,
using
=
using
)
@python_2_unicode_compatible
class
TagBase
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
_
(
'Name'
),
unique
=
True
,
max_length
=
100
)
...
...
@@ -30,17 +47,14 @@ class TagBase(models.Model):
# with a multi-master setup, theoretically we could try to
# write and rollback on different DBs
kwargs
[
"using"
]
=
using
trans_kwargs
=
{
"using"
:
using
}
i
=
0
while
True
:
i
+=
1
try
:
sid
=
transaction
.
savepoint
(
**
trans_kwargs
)
with
atomic
(
using
=
using
):
res
=
super
(
TagBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
transaction
.
savepoint_commit
(
sid
,
**
trans_kwargs
)
return
res
except
IntegrityError
:
transaction
.
savepoint_rollback
(
sid
,
**
trans_kwargs
)
self
.
slug
=
self
.
slugify
(
self
.
name
,
i
)
else
:
return
super
(
TagBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
...
...
tox.ini
View file @
c8257843
...
...
@@ -58,24 +58,6 @@ deps =
{
[testenv]
deps}
{
[testenv]
deps17}
[testenv:py32-1.5.x]
basepython
=
python3.2
deps
=
{
[testenv]
deps}
{
[testenv]
deps15}
[testenv:py32-1.6.x]
basepython
=
python3.2
deps
=
{
[testenv]
deps}
{
[testenv]
deps16}
[testenv:py32-1.7.x]
basepython
=
python3.2
deps
=
{
[testenv]
deps}
{
[testenv]
deps17}
[testenv:py33-1.5.x]
basepython
=
python3.3
deps
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment