Permalink
Browse files

Merge branch 'feature/double-monkeypatch-fix' of https://github.com/p…

…iquadrat/django-cms into hotfix/2.1.3
  • Loading branch information...
2 parents 09cda77 + 1a49a95 commit 9c0f68cf976d585e2d01de438c9cfba1b51ac4dd Jonas Obrist committed Feb 22, 2011
Showing with 19 additions and 7 deletions.
  1. +5 −6 cms/models/__init__.py
  2. +14 −1 cms/tests/multilingual.py
View
@@ -37,6 +37,8 @@ def remove_current_root(url):
return url
def monkeypatch_reverse():
+ if hasattr(django.core.urlresolvers.reverse, 'cms_monkeypatched'):
+ return
django.core.urlresolvers.old_reverse = django.core.urlresolvers.reverse
def new_reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, current_app=None):
@@ -62,13 +64,10 @@ def new_reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, cur
raise e
url = remove_current_root(url)
return url
-
+
+ new_reverse.cms_monkeypatched = True
django.core.urlresolvers.reverse = new_reverse
validate_dependencies()
validate_settings()
-
-monkeypatched = False
-if not monkeypatched:
- monkeypatch_reverse()
- monkeypatched = True
+monkeypatch_reverse()
View
@@ -61,4 +61,17 @@ def test_02_multilingual_page(self):
public = page.publisher_public
placeholder = public.placeholders.all()[0]
self.assertEqual(placeholder.cmsplugin_set.filter(language='de').count(), 1)
- self.assertEqual(placeholder.cmsplugin_set.filter(language='en').count(), 1)
+ self.assertEqual(placeholder.cmsplugin_set.filter(language='en').count(), 1)
+
+ def test_03_multiple_reverse_monkeypatch(self):
+ """
+ This test is not very well behaved, every following
+ test that uses reverse will fail with a RuntimeException.
+ """
+ from cms.models import monkeypatch_reverse
+ monkeypatch_reverse()
+ monkeypatch_reverse()
+ try:
+ reverse('foobar')
+ except RuntimeError:
+ self.fail('maximum recursion depth exceeded')

0 comments on commit 9c0f68c

Please sign in to comment.