Skip to content

Commit

Permalink
Compatability update
Browse files Browse the repository at this point in the history
pre-1.3 Django used to eat AttributeError exceptions in if statements.
Now though get_public_absolute_url returns None instead of raising
exception.
  • Loading branch information
johnsensible committed Jun 8, 2011
1 parent 6991e96 commit 81ddb1b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion publish/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = (0, 3, 3)
VERSION = (0, 3, 4)
__version__ = '.'.join(map(str, VERSION))
4 changes: 1 addition & 3 deletions publish/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions publish/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 81ddb1b

Please sign in to comment.