kopia lustrzana https://github.com/wagtail/wagtail
Python 2.6 compatibility - fixes #156
rodzic
aa09c442a2
commit
41c5c1c457
wagtail
wagtailembeds
wagtailimages
wagtailredirects
wagtailsearch
wagtailsnippets
|
@ -13,7 +13,7 @@ services:
|
|||
install:
|
||||
- python setup.py install
|
||||
- pip install psycopg2 pyelasticsearch elasticutils==0.8.2 wand
|
||||
- pip install coveralls
|
||||
- pip install coveralls unittest2
|
||||
# Pre-test configuration
|
||||
before_script:
|
||||
- psql -c 'create database wagtaildemo;' -U postgres
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# Requirements essential for developing wagtail (not needed to run it)
|
||||
|
||||
unittest2==0.5.1
|
||||
|
||||
# For coverage and PEP8 linting
|
||||
coverage==3.7.1
|
||||
flake8==2.1.0
|
||||
|
|
32
tox.ini
32
tox.ini
|
@ -1,26 +1,46 @@
|
|||
[deps]
|
||||
dj16=
|
||||
Django>=1.6,<1.7
|
||||
pyelasticsearch==0.6.1
|
||||
elasticutils==0.8.2
|
||||
unittest2
|
||||
|
||||
[tox]
|
||||
envlist =
|
||||
py26-dj16-postgres,
|
||||
py26-dj16-sqlite,
|
||||
py27-dj16-postgres,
|
||||
py27-dj16-sqlite
|
||||
|
||||
[testenv]
|
||||
commands=./runtests.py
|
||||
|
||||
[testenv:py26-dj16-postgres]
|
||||
basepython=python2.6
|
||||
deps =
|
||||
{[deps]dj16}
|
||||
psycopg2==2.5.2
|
||||
setenv =
|
||||
DATABASE_ENGINE=django.db.backends.postgresql_psycopg2
|
||||
|
||||
[testenv:py26-dj16-sqlite]
|
||||
basepython=python2.6
|
||||
deps =
|
||||
{[deps]dj16}
|
||||
setenv =
|
||||
DATABASE_ENGINE=django.db.backends.sqlite3
|
||||
|
||||
[testenv:py27-dj16-postgres]
|
||||
basepython=python2.7
|
||||
deps =
|
||||
Django>=1.6,<1.7
|
||||
{[deps]dj16}
|
||||
psycopg2==2.5.2
|
||||
pyelasticsearch==0.6.1
|
||||
elasticutils==0.8.2
|
||||
setenv =
|
||||
DATABASE_ENGINE=django.db.backends.postgresql_psycopg2
|
||||
|
||||
[testenv:py27-dj16-sqlite]
|
||||
basepython=python2.7
|
||||
deps =
|
||||
Django>=1.6,<1.7
|
||||
pyelasticsearch==0.6.1
|
||||
elasticutils==0.8.2
|
||||
{[deps]dj16}
|
||||
setenv =
|
||||
DATABASE_ENGINE=django.db.backends.sqlite3
|
||||
|
|
|
@ -12,7 +12,7 @@ class SearchForm(forms.Form):
|
|||
if _placeholder is not None:
|
||||
placeholder = _placeholder
|
||||
else:
|
||||
placeholder = 'Search {}'.format(placeholder_suffix)
|
||||
placeholder = 'Search {0}'.format(placeholder_suffix)
|
||||
self.fields['q'].widget.attrs = {'placeholder': placeholder}
|
||||
|
||||
q = forms.CharField(label=_("Search term"), widget=forms.TextInput())
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from django.conf import settings
|
||||
from django.utils.importlib import import_module
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# for Python 2.6, fall back on django.utils.importlib (deprecated as of Django 1.7)
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
_hooks = {}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.test import TestCase
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
from wagtail.tests.models import SimplePage, EventPage
|
||||
from wagtail.tests.utils import login
|
||||
from wagtail.wagtailcore.models import Page
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import sys
|
||||
from importlib import import_module
|
||||
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# for Python 2.6, fall back on django.utils.importlib (deprecated as of Django 1.7)
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from datetime import datetime
|
||||
from django.utils import six
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
# Based on the Django cache framework and wagtailsearch
|
||||
# https://github.com/django/django/blob/5d263dee304fdaf95e18d2f0619d6925984a7f02/django/core/cache/__init__.py
|
||||
|
||||
from importlib import import_module
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# for Python 2.6, fall back on django.utils.importlib (deprecated as of Django 1.7)
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.utils import six
|
||||
import sys
|
||||
from django.conf import settings
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
from django.conf import settings
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.html import escape
|
||||
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# for Python 2.6, fall back on django.utils.importlib (deprecated as of Django 1.7)
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
class Format(object):
|
||||
def __init__(self, name, label, classnames, filter_spec):
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.contrib.auth.models import User, Group, Permission
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
|
||||
from wagtail.tests.utils import login
|
||||
from wagtail.wagtailimages.models import get_image_model
|
||||
|
|
|
@ -109,7 +109,7 @@ def add(request):
|
|||
theredirect.site = request.site
|
||||
theredirect.save()
|
||||
|
||||
messages.success(request, _("Redirect '{0} added.").format(theredirect.title))
|
||||
messages.success(request, _("Redirect '{0}' added.").format(theredirect.title))
|
||||
return redirect('wagtailredirects_index')
|
||||
else:
|
||||
messages.error(request, _("The redirect could not be created due to errors."))
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
# Based on the Django cache framework
|
||||
# https://github.com/django/django/blob/5d263dee304fdaf95e18d2f0619d6925984a7f02/django/core/cache/__init__.py
|
||||
|
||||
from importlib import import_module
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
# for Python 2.6, fall back on django.utils.importlib (deprecated as of Django 1.7)
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.utils import six
|
||||
import sys
|
||||
from django.conf import settings
|
||||
|
|
|
@ -37,7 +37,7 @@ class ElasticSearchResults(object):
|
|||
results = results.prefetch_related(prefetch)
|
||||
|
||||
# Put results into a dictionary (using primary key as the key)
|
||||
results_dict = {str(result.pk): result for result in results}
|
||||
results_dict = dict((str(result.pk), result) for result in results)
|
||||
|
||||
# Build new list with items in the correct order
|
||||
results_sorted = [results_dict[str(pk)] for pk in pk_list if str(pk) in results_dict]
|
||||
|
|
|
@ -40,7 +40,7 @@ class Indexed(object):
|
|||
if isinstance(indexed_fields, basestring):
|
||||
indexed_fields = [indexed_fields]
|
||||
if isinstance(indexed_fields, list):
|
||||
indexed_fields = {field: dict(type="string") for field in indexed_fields}
|
||||
indexed_fields = dict((field, dict(type="string")) for field in indexed_fields)
|
||||
if not isinstance(indexed_fields, dict):
|
||||
raise ValueError()
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.test import TestCase
|
|||
from django.test.utils import override_settings
|
||||
from django.conf import settings
|
||||
from django.core import management
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
from wagtail.wagtailsearch import models, get_search_backend
|
||||
from wagtail.wagtailsearch.backends.db import DBSearch
|
||||
from wagtail.wagtailsearch.backends import InvalidSearchBackendError
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.core import management
|
|||
from wagtail.wagtailsearch import models
|
||||
from wagtail.tests.utils import login
|
||||
from StringIO import StringIO
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
|
||||
|
||||
class TestHitCounter(TestCase):
|
||||
|
|
|
@ -73,11 +73,11 @@ def search(
|
|||
for result in search_results:
|
||||
result_specific = result.specific
|
||||
|
||||
search_results_json.append({
|
||||
attr: getattr(result_specific, attr)
|
||||
search_results_json.append(dict(
|
||||
(attr, getattr(result_specific, attr))
|
||||
for attr in json_attrs
|
||||
if hasattr(result_specific, attr)
|
||||
})
|
||||
))
|
||||
|
||||
return HttpResponse(json.dumps(search_results_json))
|
||||
else:
|
||||
|
|
|
@ -5,7 +5,7 @@ when you run "manage.py test".
|
|||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue