Repository: wagtail/wagtail

Issue:
RoutablePage throws a TypeError if index route is not set
RoutablePage should not raise TypeError if index route is not set. 

[route method](https://github.com/torchbox/wagtail/blob/master/wagtail/contrib/wagtailroutablepage/models.py#L97) properly calls parent class method if route is not found, but `serve` method has different signature, so it fails.

There is also a discussion of similar issue on Google groups:
https://groups.google.com/forum/#!msg/wagtail/Q9FymA-MOxM/1UkQ0hRGAAAJ



Discussion:

Resolving patch:
diff --git a/wagtail/contrib/wagtailroutablepage/models.py b/wagtail/contrib/wagtailroutablepage/models.py
--- a/wagtail/contrib/wagtailroutablepage/models.py
+++ b/wagtail/contrib/wagtailroutablepage/models.py
@@ -96,7 +96,13 @@ def route(self, request, path_components):
 
         return super(RoutablePageMixin, self).route(request, path_components)
 
-    def serve(self, request, view, args, kwargs):
+    def serve(self, request, view=None, args=None, kwargs=None):
+        if args is None:
+            args = []
+        if kwargs is None:
+            kwargs = {}
+        if view is None:
+            return super(RoutablePageMixin, self).serve(request, *args, **kwargs)
         return view(request, *args, **kwargs)
 
     def serve_preview(self, request, mode_name):


Test patch:
diff --git a/wagtail/contrib/wagtailroutablepage/tests.py b/wagtail/contrib/wagtailroutablepage/tests.py
--- a/wagtail/contrib/wagtailroutablepage/tests.py
+++ b/wagtail/contrib/wagtailroutablepage/tests.py
@@ -5,7 +5,7 @@
 
 from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import \
     routablepageurl
-from wagtail.tests.routablepage.models import RoutablePageTest
+from wagtail.tests.routablepage.models import RoutablePageTest, RoutablePageWithoutIndexRouteTest
 from wagtail.wagtailcore.models import Page, Site
 
 
@@ -93,6 +93,16 @@ def test_get_main_view(self):
 
         self.assertContains(response, "MAIN VIEW")
 
+    def test_get_routable_page_without_index_route(self):
+        page = self.home_page.add_child(
+            instance=RoutablePageWithoutIndexRouteTest(
+                title="Routable Page without index",
+                live=True
+            )
+        )
+        response = self.client.get(page.url)
+        self.assertContains(response, "DEFAULT PAGE TEMPLATE")
+
     def test_get_archive_by_year_view(self):
         response = self.client.get(self.routable_page.url + 'archive/year/2014/')
 
diff --git a/wagtail/tests/routablepage/migrations/0002_routablepagewithoutindexroutetest.py b/wagtail/tests/routablepage/migrations/0002_routablepagewithoutindexroutetest.py
new file mode 100644
--- /dev/null
+++ b/wagtail/tests/routablepage/migrations/0002_routablepagewithoutindexroutetest.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.6 on 2016-05-10 10:31
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import wagtail.contrib.wagtailroutablepage.models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('wagtailcore', '0028_merge'),
+        ('routablepagetests', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='RoutablePageWithoutIndexRouteTest',
+            fields=[
+                ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
+        ),
+    ]
diff --git a/wagtail/tests/routablepage/models.py b/wagtail/tests/routablepage/models.py
--- a/wagtail/tests/routablepage/models.py
+++ b/wagtail/tests/routablepage/models.py
@@ -32,3 +32,7 @@ def external_view(self, *args, **kwargs):
     @route(r'^override-name-test/$', name='name_overridden')
     def override_name_test(self, request):
         pass
+
+
+class RoutablePageWithoutIndexRouteTest(RoutablePage):
+    pass
diff --git a/wagtail/tests/routablepage/templates/routablepagetests/routable_page_without_index_route_test.html b/wagtail/tests/routablepage/templates/routablepagetests/routable_page_without_index_route_test.html
new file mode 100644
--- /dev/null
+++ b/wagtail/tests/routablepage/templates/routablepagetests/routable_page_without_index_route_test.html
@@ -0,0 +1 @@
+DEFAULT PAGE TEMPLATE