From 3ae61c17b6c22c1d4cf76ed0fed838531305cb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Furma=C5=84ski?= Date: Fri, 5 Aug 2016 10:31:46 +0200 Subject: [PATCH] Fix #69: Replace NoArgsCommand with BaseCommand (django 1.10) --- django_cassandra_engine/__init__.py | 2 +- .../management/commands/sync_cassandra.py | 36 ++++++++++++------- docs/changelog.md | 4 +++ mkdocs.yml | 2 +- requirements.txt | 4 +-- testproject/runtests.py | 5 --- testproject/urls.py | 12 ++++--- tox.ini | 7 +++- 8 files changed, 44 insertions(+), 28 deletions(-) diff --git a/django_cassandra_engine/__init__.py b/django_cassandra_engine/__init__.py index 56d5cd6..ee695ab 100644 --- a/django_cassandra_engine/__init__.py +++ b/django_cassandra_engine/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Do not forget to change version number in mkdocs.yml also! -__version__ = (0, 10, 1) +__version__ = (0, 11, 0) __author__ = "Rafał Furmański" __contact__ = "r.furmanski@gmail.com" __homepage__ = "http://github.com/r4fek/django-cassandra-engine" diff --git a/django_cassandra_engine/management/commands/sync_cassandra.py b/django_cassandra_engine/management/commands/sync_cassandra.py index c6d6fc1..bff72db 100644 --- a/django_cassandra_engine/management/commands/sync_cassandra.py +++ b/django_cassandra_engine/management/commands/sync_cassandra.py @@ -1,6 +1,11 @@ -from optparse import make_option +import django +if django.VERSION[0:2] >= (1, 10): + from django.core.management.base import BaseCommand, CommandError +else: + from django.core.management.base import ( + NoArgsCommand as BaseCommand, + CommandError) -from django.core.management.base import NoArgsCommand, CommandError from django.db import connections from django.conf import settings @@ -20,7 +25,9 @@ def emit_post_migrate_signal(verbosity, interactive, db): if app_config.models_module is None: continue if verbosity >= 2: - print("Running post-migrate handlers for application %s" % app_config.label) + print("Running post-migrate handlers for application %s" % + app_config.label) + post_migrate.send( sender=app_config, app_config=app_config, @@ -29,14 +36,18 @@ def emit_post_migrate_signal(verbosity, interactive, db): using=db) -class Command(NoArgsCommand): - option_list = NoArgsCommand.option_list + ( - make_option('--database', action='store', dest='database', - default=None, help='Nominates a database to synchronize.'), - ) - +class Command(BaseCommand): help = 'Sync Cassandra database(s)' + def add_arguments(self, parser): + parser.add_argument( + '--database', + action='store', + dest='database', + default=None, + help='Nominates a database to synchronize.', + ) + @staticmethod def _import_management(): """ @@ -92,8 +103,7 @@ def sync(self, alias): self.stdout.write('Syncing %s.%s' % (app_name, model.__name__)) sync_table(model) - def handle_noargs(self, **options): - + def handle(self, *args, **options): self._import_management() database = options.get('database') @@ -111,6 +121,6 @@ def handle_noargs(self, **options): raise CommandError( 'Please add django_cassandra_engine backend to DATABASES!') - # Send the post_migrate signal, so individual apps can do whatever they need - # to do at this point. + # Send the post_migrate signal, so individual apps can do whatever + # they need to do at this point. emit_post_migrate_signal(1, False, cassandra_alias) diff --git a/docs/changelog.md b/docs/changelog.md index 703eeb4..0756cd6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Django Cassandra Engine - CHANGELOG +## Version 1.11.0 (05.08.2016) + +* Fix #69: Replace NoArgsCommand with BaseCommand to accommodate 1.10 upgrade (by @BenBrostoff) + ## Version 0.10.1 (22.07.2016) * Update `cassandra-driver` to 3.5.0 diff --git a/mkdocs.yml b/mkdocs.yml index 034ff12..f8b1d5d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -12,7 +12,7 @@ repo_url: https://github.com/r4fek/django-cassandra-engine # Options extra: - version: 0.10.1 + version: 0.11.0 logo: images/dj_cassandra.png author: github: r4fek diff --git a/requirements.txt b/requirements.txt index ed8d0a9..5f13ec9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -cassandra-driver==3.5.0 -Django<1.10 +cassandra-driver==3.6.0 +Django<1.11 six>=1.6 diff --git a/testproject/runtests.py b/testproject/runtests.py index 05cc59f..ce33536 100755 --- a/testproject/runtests.py +++ b/testproject/runtests.py @@ -27,11 +27,6 @@ def run_tests(foo, settings='settings', extra=(), test_builtin=False): apps = [ name for name in apps if not name.startswith('django.contrib.')] - # pre-1.6 test runners don't understand full module names - if django.VERSION < (1, 6): - apps = [app.replace('django.contrib.', '') for app in apps] - apps = [name for name in apps if not name.startswith('testproject.')] - os.chdir(test_dir) print('\n============================\n' 'Running tests with settings: {}\n' diff --git a/testproject/urls.py b/testproject/urls.py index 5a8e97e..f7bf7e4 100644 --- a/testproject/urls.py +++ b/testproject/urls.py @@ -1,12 +1,14 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.contrib import admin -admin.autodiscover() -urlpatterns = patterns('', +from testproject.app import views + + +urlpatterns = [ # Examples: - url(r'^$', 'app.views.home', name='home'), + url(r'^$', views.home, name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), -) +] diff --git a/tox.ini b/tox.ini index dcc3fdb..f1b9fb0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = django{17,18,19} +envlist = django{17,18,19,110} [base] deps = nose @@ -25,3 +25,8 @@ deps = deps = django>=1.9, <1.10 {[base]deps} + +[testenv:django110] +deps = + django>=1.9, <1.11 + {[base]deps}