From 6b3693f35522352f8c095f64e3ea9558aacad593 Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 10 Jul 2014 16:44:08 +0100 Subject: [PATCH 1/9] Typos in 0.4 release notes --- docs/releases/0.4.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/releases/0.4.rst b/docs/releases/0.4.rst index a2f78e20c..afd8ccff5 100644 --- a/docs/releases/0.4.rst +++ b/docs/releases/0.4.rst @@ -3,14 +3,14 @@ Wagtail 0.4 release notes ========================= -Whats new -========= +What's new +========== Private Pages ~~~~~~~~~~~~~ -Wagtail now supports password protecting pages on the frontend allowing sections of your website to be made private. +Wagtail now supports password protecting pages on the frontend, allowing sections of your website to be made private. :ref:`private_pages` @@ -26,13 +26,13 @@ Scheduled publishing Editors can now schedule pages to be published or unpublished at specified times. -A new management command has been added (:ref:`publish_scheduled_pages`) to publish pages that have been scheduled by an Editor. +A new management command has been added (:ref:`publish_scheduled_pages`) to publish pages that have been scheduled by an editor. Search on QuerySet with Elasticsearch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Its now possible to perform searches with Elasticsearch on ``PageQuerySet`` objects: +It's now possible to perform searches with Elasticsearch on ``PageQuerySet`` objects: >>> from wagtail.wagtailcore.models import Page >>> Page.objects.live().descendant_of(events_index).search("Hello") @@ -58,7 +58,7 @@ A new module has been added (``wagtail.contrib.wagtailfrontendcache``) which inv Notification preferences ~~~~~~~~~~~~~~~~~~~~~~~~ -Users can now decide which notifications they recieve from Wagtail using a new "Notification preferences" section located in the account settings. +Users can now decide which notifications they receive from Wagtail using a new "Notification preferences" section located in the account settings. Minor features @@ -114,22 +114,22 @@ Images Other ----- - * Added styleguide (mainly for wagtail developers) + * Added styleguide, for Wagtail developers Bug fixes ~~~~~~~~~ * Animated GIFs are now coalesced before resizing - * Wand backend clones images before modifying them - * Admin breadcrumb now positioned correctly on mobile - * Page chooser breadcrumb now updates the chooser modal instead of linking to Explorer - * Embeds - Fixed crash when no HTML field is sent back from the embed provider + * The Wand backend clones images before modifying them + * The admin breadcrumb is now positioned correctly on mobile + * The page chooser breadcrumb now updates the chooser modal instead of linking to Explorer + * Embeds - fixed crash when no HTML field is sent back from the embed provider * Multiple sites with same hostname but different ports are now allowed - * No longer possible to create multiple sites with ``is_default_site = True`` + * It is no longer possible to create multiple sites with ``is_default_site = True`` -Backwards incompatible changes +Backwards-incompatible changes ============================== From 812daf0662557b7a4da18a7a4bc4a7492c1c72e1 Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Thu, 10 Jul 2014 17:11:03 +0100 Subject: [PATCH 2/9] Added contents --- docs/releases/0.4.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/releases/0.4.rst b/docs/releases/0.4.rst index afd8ccff5..64259a191 100644 --- a/docs/releases/0.4.rst +++ b/docs/releases/0.4.rst @@ -2,6 +2,9 @@ Wagtail 0.4 release notes ========================= +.. contents:: Contents + :local: + What's new ========== From 6f1a78bedf182344941d133038a87ed499ecb78d Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 10 Jul 2014 17:20:48 +0100 Subject: [PATCH 3/9] python -> Python --- docs/search/for_python_developers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/search/for_python_developers.rst b/docs/search/for_python_developers.rst index 7ff9a18dc..1cadbc8da 100644 --- a/docs/search/for_python_developers.rst +++ b/docs/search/for_python_developers.rst @@ -3,7 +3,7 @@ ===================== -For python developers +For Python developers ===================== From be0080a8aff099818b5374f5b397c6fd2662e3ab Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Thu, 10 Jul 2014 17:22:07 +0100 Subject: [PATCH 4/9] Update private_pages.rst --- docs/private_pages.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/private_pages.rst b/docs/private_pages.rst index bfd20ee09..99b364176 100644 --- a/docs/private_pages.rst +++ b/docs/private_pages.rst @@ -21,7 +21,7 @@ This template will receive the same set of context variables that the blocked pa - **form** - A Django form object for the password prompt; this will contain a field named ``password`` as its only visible field. A number of hidden fields may also be present, so the page must loop over ``form.hidden_fields`` if not using one of Django's rendering helpers such as ``form.as_p``. - **action_url** - The URL that the password form should be submitted to, as a POST request. -A basic template suitable for use as PASSWORD_REQUIRED_TEMPLATE might look like this: +A basic template suitable for use as ``PASSWORD_REQUIRED_TEMPLATE`` might look like this: .. code-block:: django From 51c6f251e2422cf66b26a88eea8ed1db39e20050 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 14 Jul 2014 11:30:54 +0100 Subject: [PATCH 5/9] Made contents a bit smaller --- docs/releases/0.4.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/releases/0.4.rst b/docs/releases/0.4.rst index 64259a191..0929935f6 100644 --- a/docs/releases/0.4.rst +++ b/docs/releases/0.4.rst @@ -2,8 +2,9 @@ Wagtail 0.4 release notes ========================= -.. contents:: Contents +.. contents:: :local: + :depth: 1 What's new From 494a26b731ed4a8e573bfc1a0410c46349a9ef1f Mon Sep 17 00:00:00 2001 From: Tom Dyson Date: Thu, 10 Jul 2014 17:28:07 +0100 Subject: [PATCH 6/9] consistent editors / editor's / Editor's --- docs/search/editors_picks.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/search/editors_picks.rst b/docs/search/editors_picks.rst index 9ed41f3c5..59ae647de 100644 --- a/docs/search/editors_picks.rst +++ b/docs/search/editors_picks.rst @@ -2,10 +2,10 @@ .. _editors-picks: -Editors picks -============= +Editor's picks +============== -Editor's Picks are a way of explicitly linking relevant content to search terms, so results pages can contain curated content instead of being at the mercy of the search algorithm. In a template using the search results view, editor's picks can be accessed through the variable ``query.editors_picks``. To include editor's picks in your search results template, use the following properties. +Editor's picks are a way of explicitly linking relevant content to search terms, so results pages can contain curated content in addition to results from the search algorithm. In a template using the search results view, editor's picks can be accessed through the variable ``query.editors_picks``. To include editor's picks in your search results template, use the following properties. ``query.editors_picks.all`` This gathers all of the editor's picks objects relating to the current query, in order according to their sort order in the Wagtail admin. You can then iterate through them using a ``{% for ... %}`` loop. Each editor's pick object provides these properties: @@ -16,7 +16,7 @@ Editor's Picks are a way of explicitly linking relevant content to search terms, ``editors_pick.description`` The description entered when choosing the pick, perhaps explaining why the page is relevant to the search terms. -Putting this all together, a block of your search results template displaying editor's Picks might look like this: +Putting this all together, a block of your search results template displaying editor's picks might look like this: .. code-block:: django @@ -38,4 +38,4 @@ Putting this all together, a block of your search results template displaying ed {% endif %} - {% endwith %} \ No newline at end of file + {% endwith %} From 930833324de095eb7e3bc4e9df5f75da60ee3cd2 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 14 Jul 2014 10:50:30 +0100 Subject: [PATCH 7/9] Fixed backwards compatibility with Elasticsearch URLs setting --- .../wagtailsearch/backends/elasticsearch.py | 23 +++++++-- .../tests/test_elasticsearch_backend.py | 51 +++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/wagtail/wagtailsearch/backends/elasticsearch.py b/wagtail/wagtailsearch/backends/elasticsearch.py index 55f1971a2..8f8a78dbb 100644 --- a/wagtail/wagtailsearch/backends/elasticsearch.py +++ b/wagtail/wagtailsearch/backends/elasticsearch.py @@ -2,6 +2,8 @@ from __future__ import absolute_import import json +from six.moves.urllib.parse import urlparse + from django.db import models from django.db.models.sql.where import SubqueryConstraint @@ -446,17 +448,30 @@ class ElasticSearch(BaseSearch): super(ElasticSearch, self).__init__(params) # Get settings + self.es_hosts = params.pop('HOSTS', None) self.es_urls = params.pop('URLS', ['http://localhost:9200']) self.es_index = params.pop('INDEX', 'wagtail') - self.es_timeout = params.pop('TIMEOUT', 5) - self.es_force_new = params.pop('FORCE_NEW', False) + self.es_timeout = params.pop('TIMEOUT', 10) + + # If HOSTS is not set, convert URLS setting to HOSTS + if self.es_hosts is None: + self.es_hosts = [] + + for url in self.es_urls: + parsed_url = urlparse(url) + + self.es_hosts.append({ + 'host': parsed_url.hostname, + 'port': parsed_url.port or 9200, + 'url_prefix': parsed_url.path, + 'use_ssl': parsed_url.scheme == 'https', + }) # Get ElasticSearch interface # Any remaining params are passed into the ElasticSearch constructor self.es = Elasticsearch( - urls=self.es_urls, + hosts=self.es_hosts, timeout=self.es_timeout, - force_new=self.es_force_new, **params) def reset_index(self): diff --git a/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py b/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py index a95d442ff..3ddce5618 100644 --- a/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py +++ b/wagtail/wagtailsearch/tests/test_elasticsearch_backend.py @@ -397,3 +397,54 @@ class TestElasticSearchMappingInheritance(TestCase): } self.assertDictEqual(document, expected_result) + + +class TestBackendConfiguration(TestCase): + def setUp(self): + # Import using a try-catch block to prevent crashes if the elasticsearch-py + # module is not installed + try: + from wagtail.wagtailsearch.backends.elasticsearch import ElasticSearch + except ImportError: + raise unittest.SkipTest("elasticsearch-py not installed") + + self.ElasticSearch = ElasticSearch + + def test_default_settings(self): + backend = self.ElasticSearch(params={}) + + self.assertEqual(len(backend.es_hosts), 1) + self.assertEqual(backend.es_hosts[0]['host'], 'localhost') + self.assertEqual(backend.es_hosts[0]['port'], 9200) + self.assertEqual(backend.es_hosts[0]['use_ssl'], False) + + def test_hosts(self): + # This tests that HOSTS goes to es_hosts + backend = self.ElasticSearch(params={ + 'HOSTS': [ + { + 'host': '127.0.0.1', + 'port': 9300, + 'use_ssl': True, + } + ] + }) + + self.assertEqual(len(backend.es_hosts), 1) + self.assertEqual(backend.es_hosts[0]['host'], '127.0.0.1') + self.assertEqual(backend.es_hosts[0]['port'], 9300) + self.assertEqual(backend.es_hosts[0]['use_ssl'], True) + + def test_urls(self): + # This test backwards compatibility with old URLS setting + backend = self.ElasticSearch(params={ + 'URLS': ['http://localhost:12345', 'https://127.0.0.1:54321'], + }) + + self.assertEqual(len(backend.es_hosts), 2) + self.assertEqual(backend.es_hosts[0]['host'], 'localhost') + self.assertEqual(backend.es_hosts[0]['port'], 12345) + self.assertEqual(backend.es_hosts[0]['use_ssl'], False) + self.assertEqual(backend.es_hosts[1]['host'], '127.0.0.1') + self.assertEqual(backend.es_hosts[1]['port'], 54321) + self.assertEqual(backend.es_hosts[1]['use_ssl'], True) From cc446f0e9735d0f051e5608e22203f498a2412c2 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 14 Jul 2014 10:58:50 +0100 Subject: [PATCH 8/9] FORCE_NEW is not used in Elasticsearch-py --- docs/search/backends.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/search/backends.rst b/docs/search/backends.rst index f03f06358..471da751a 100644 --- a/docs/search/backends.rst +++ b/docs/search/backends.rst @@ -41,11 +41,10 @@ The backend is configured in settings: 'URLS': ['http://localhost:9200'], 'INDEX': 'wagtail', 'TIMEOUT': 5, - 'FORCE_NEW': False, } } -Other than ``BACKEND`` the keys are optional and default to the values shown. ``FORCE_NEW`` is used by elasticsearch-py. In addition, any other keys are passed directly to the Elasticsearch constructor as case-sensitive keyword arguments (e.g. ``'max_retries': 1``). +Other than ``BACKEND`` the keys are optional and default to the values shown. In addition, any other keys are passed directly to the Elasticsearch constructor as case-sensitive keyword arguments (e.g. ``'max_retries': 1``). If you prefer not to run an Elasticsearch server in development or production, there are many hosted services available, including `Searchly`_, who offer a free account suitable for testing and development. To use Searchly: From 0d5f0172eb93428022430dcf51fca2062b451955 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 14 Jul 2014 13:12:04 +0100 Subject: [PATCH 9/9] add release notes / changelog entry for 0.4.1 --- CHANGELOG.txt | 5 +++++ docs/releases/0.4.1.rst | 9 +++++++++ docs/releases/index.rst | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 docs/releases/0.4.1.rst diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a0abb58db..c6db3355e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,11 @@ Changelog ========= +0.4.1 (14.07.2014) +~~~~~~~~~~~~~~~~~~ + * ElasticSearch backend now respects the backward-compatible URLS configuration setting, in addition to HOSTS + * Documentation fixes + 0.4 (10.07.2014) ~~~~~~~~~~~~~~~~ * ElasticUtils/pyelasticsearch swapped for elasticsearch-py diff --git a/docs/releases/0.4.1.rst b/docs/releases/0.4.1.rst new file mode 100644 index 000000000..802a555af --- /dev/null +++ b/docs/releases/0.4.1.rst @@ -0,0 +1,9 @@ +=========================== +Wagtail 0.4.1 release notes +=========================== + +Bug fixes +~~~~~~~~~ + + * ElasticSearch backend now respects the backward-compatible URLS configuration setting, in addition to HOSTS + * Documentation fixes diff --git a/docs/releases/index.rst b/docs/releases/index.rst index 07bc8e888..35d3947ae 100644 --- a/docs/releases/index.rst +++ b/docs/releases/index.rst @@ -4,4 +4,5 @@ Release notes .. toctree:: :maxdepth: 1 - 0.4 \ No newline at end of file + 0.4 + 0.4.1