Skip to content

Commit

Permalink
removes DBNAME env var and force db name to 'concurrency'
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jul 21, 2014
1 parent 321da3e commit 658d4a1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
- PostgreSQL
python:
- 2.7
- 3.2
- 3.3

env:
- DJANGO="1.4.x" DBENGINE=mysql
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DJANGO_15='django>=1.5,<1.6'
DJANGO_16='django>=1.6,>1.7'
DJANGO_17='https://www.djangoproject.com/download/1.7c1/tarball/'
DJANGO_DEV=git+git://github.com/django/django.git
DBNAME=concurrency




Expand All @@ -27,12 +27,12 @@ locale:


init-db:
@sh -c "if [ '${DBENGINE}' = 'mysql' ]; then mysql -e 'DROP DATABASE IF EXISTS ${DBNAME};'; fi"
@sh -c "if [ '${DBENGINE}' = 'mysql' ]; then mysql -e 'DROP DATABASE IF EXISTS concurrency;'; fi"
@sh -c "if [ '${DBENGINE}' = 'mysql' ]; then pip install MySQL-python; fi"
@sh -c "if [ '${DBENGINE}' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS ${DBNAME};'; fi"
@sh -c "if [ '${DBENGINE}' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS concurrency;'; fi"

@sh -c "if [ '${DBENGINE}' = 'pg' ]; then psql -c 'DROP DATABASE IF EXISTS ${DBNAME};' -U postgres; fi"
@sh -c "if [ '${DBENGINE}' = 'pg' ]; then psql -c 'CREATE DATABASE ${DBNAME};' -U postgres; fi"
@sh -c "if [ '${DBENGINE}' = 'pg' ]; then psql -c 'DROP DATABASE IF EXISTS concurrency;' -U postgres; fi"
@sh -c "if [ '${DBENGINE}' = 'pg' ]; then psql -c 'CREATE DATABASE concurrency;' -U postgres; fi"
@sh -c "if [ '${DBENGINE}' = 'pg' ]; then pip install -q psycopg2; fi"


Expand Down
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Django Concurrency

django-concurrency is an optimistic lock [1]_ implementation for Django.

Tested with: 1.4.x, 1.5.x, 1.6.x, trunk.
Tested with: 1.4.x, 1.5.x, 1.6.x, 1.7rc1 trunk.

It prevents users from doing concurrent editing in Django both from UI and from a
django command.
Expand Down Expand Up @@ -44,9 +44,9 @@ Other projects that handle concurrent editing are `django-optimistic-lock`_ and

* can be applied to any model; not only your code (ie. django.contrib.auth.Group)
* works with django 1.4 and 1.5
* handle `list-editable`_ ChangeList. (solves `#11313 <https://code.djangoproject.com/ticket/11313>`_)
* handle concurrency in admin's actions
* can intercept changes performend out of the django app (ie using pgAdmin, phpMyAdmin, Toads)
* handle `list-editable`_ ChangeList. (handle `#11313 <https://code.djangoproject.com/ticket/11313>`_)
* manage concurrency conflicts in admin's actions
* can intercept changes performend out of the django app (ie using pgAdmin, phpMyAdmin, Toads) (using `TriggerVersionField_`


Links
Expand Down Expand Up @@ -96,5 +96,7 @@ Links

.. _django-optimistic-lock: https://github.com/gavinwahl/django-optimistic-lock

.. _TriggerVersionField: https://django-concurrency.readthedocs.org/en/latest/fields.html#triggerversionfield

.. [1] http://en.wikipedia.org/wiki/Optimistic_concurrency_control
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def pytest_configure(config):
if not settings.configured:
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'

from concurrency.api import apply_concurrency_check
from django.contrib.auth.models import Permission
from concurrency.fields import IntegerVersionField

apply_concurrency_check(Permission, 'version', IntegerVersionField)
# from concurrency.api import apply_concurrency_check
# from django.contrib.auth.models import Permission
# from concurrency.fields import IntegerVersionField
#
# apply_concurrency_check(Permission, 'version', IntegerVersionField)

try:
from django.apps import AppConfig # noqa
Expand Down
7 changes: 3 additions & 4 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@
}
}

DBNAME = os.environ.get('DBNAME', 'concurrency')
db = os.environ.get('DBENGINE', None)
if db == 'pg':
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': 'concurrency.db.backends.postgresql_psycopg2',
'NAME': DBNAME,
'NAME': 'concurrency',
'HOST': '127.0.0.1',
'PORT': '',
'USER': 'postgres',
Expand All @@ -95,7 +94,7 @@
'default': {
# 'ENGINE': 'django.db.backends.mysql',
'ENGINE': 'concurrency.db.backends.mysql',
'NAME': DBNAME,
'NAME': 'concurrency',
'HOST': '127.0.0.1',
'PORT': '',
'USER': 'root',
Expand All @@ -108,6 +107,6 @@
DATABASES = {
'default': {
'ENGINE': 'concurrency.db.backends.sqlite3',
'NAME': '%s.sqlite' % DBNAME,
'NAME': 'concurrency.sqlite',
'HOST': '',
'PORT': ''}}

0 comments on commit 658d4a1

Please sign in to comment.