Browse files

fixed apphooks with includes in their urlpatterns breaking in 1.4

  • Loading branch information...
1 parent 4129798 commit 913ad268f6dc62226294e2dcc6d18741d39385ec @ojii ojii committed Jun 28, 2012
Showing with 10 additions and 8 deletions.
  1. +3 −2 cms/appresolver.py
  2. +1 −1 cms/test_utils/project/sampleapp/urls.py
  3. +6 −5 cms/tests/apphooks.py
View
5 cms/appresolver.py
@@ -76,8 +76,9 @@ def recurse_patterns(path, pattern_list, page_id):
newpatterns = []
for pattern in pattern_list:
app_pat = pattern.regex.pattern
- if app_pat.startswith('^'):
- app_pat = app_pat[1:]
+ # make sure we don't get patterns that start with more than one '^'!
+ app_pat = app_pat.lstrip('^')
+ path = path.lstrip('^')
regex = r'^%s%s' % (path, app_pat)
if isinstance(pattern, RegexURLResolver):
# this is an 'include', recurse!
View
2 cms/test_utils/project/sampleapp/urls.py
@@ -12,5 +12,5 @@
url(r'(?P<id>[0-9]+)/$', 'category_view', name='category_view'),
url(r'notfound/$', 'notfound', name='notfound'),
url(r'extra_1/$', 'extra_view', {'message': 'test urlconf'}, name='extra_first'),
- url(r'^', include('cms.test_utils.project.sampleapp.urls_extra')),
+ url(r'', include('cms.test_utils.project.sampleapp.urls_extra')),
)
View
11 cms/tests/apphooks.py
@@ -153,17 +153,18 @@ def test_include_urlconf(self):
create_title("de", child_child_page.get_title(), child_child_page, apphook='SampleApp')
child_child_page.publish()
- path = reverse('extra_first')
- response = self.client.get(path)
- self.assertEquals(response.status_code, 200)
- self.assertTemplateUsed(response, 'sampleapp/extra.html')
- self.assertContains(response, "test urlconf")
path = reverse('extra_second')
response = self.client.get(path)
self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'sampleapp/extra.html')
self.assertContains(response, "test included urlconf")
+
+ path = reverse('extra_first')
+ response = self.client.get(path)
+ self.assertEquals(response.status_code, 200)
+ self.assertTemplateUsed(response, 'sampleapp/extra.html')
+ self.assertContains(response, "test urlconf")
path = reverse('de:extra_first')
response = self.client.get(path)

0 comments on commit 913ad26

Please sign in to comment.