From 81ddb1b0b3344d9eef8d7e8bf46f24f3145a566f Mon Sep 17 00:00:00 2001 From: John Montgomery Date: Wed, 8 Jun 2011 13:33:40 +0100 Subject: [PATCH] Compatability update pre-1.3 Django used to eat AttributeError exceptions in if statements. Now though get_public_absolute_url returns None instead of raising exception. --- publish/__init__.py | 2 +- publish/models.py | 4 +--- publish/tests.py | 7 ++----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/publish/__init__.py b/publish/__init__.py index d0e146c..bf6db0f 100644 --- a/publish/__init__.py +++ b/publish/__init__.py @@ -1,2 +1,2 @@ -VERSION = (0, 3, 3) +VERSION = (0, 3, 4) __version__ = '.'.join(map(str, VERSION)) diff --git a/publish/models.py b/publish/models.py index fd5e883..6874c18 100644 --- a/publish/models.py +++ b/publish/models.py @@ -157,9 +157,7 @@ def is_marked_for_deletion(self): def get_public_absolute_url(self): if self.public: return self.public.get_absolute_url() - # effectively this method doesn't exist until we - # have a public instance - raise AttributeError("get_public_absolute_url") + return None def save(self, mark_changed=True, *arg, **kw): if not self.is_public and mark_changed: diff --git a/publish/tests.py b/publish/tests.py index 0439a3a..5122bc9 100644 --- a/publish/tests.py +++ b/publish/tests.py @@ -107,11 +107,7 @@ def setUp(self): def test_get_public_absolute_url(self): self.failUnlessEqual('/my-page*', self.flat_page.get_absolute_url()) # public absolute url doesn't exist until published - try: - self.flat_page.get_public_absolute_url() - self.fail() - except AttributeError: - pass + self.assertTrue(self.flat_page.get_public_absolute_url() is None) self.flat_page.save() self.flat_page.publish() self.failUnlessEqual('/my-page', self.flat_page.get_public_absolute_url()) @@ -1058,6 +1054,7 @@ def test_publish_selected_confirm(self): pages = Page.objects.exclude(id=self.fp3.id) class dummy_request(object): + META = {} POST = {} class user(object):