From e971959755f26129fc79a77c3aeee1db0f7e6e41 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 26 May 2008 23:00:31 -0700 Subject: [PATCH] Attempting to access the RSS feed for a non-existent notebook now displays a somewhat informative message in the feed instead of just silently raising an error. --- NEWS | 5 +++++ controller/Notebooks.py | 7 ++++++- controller/test/Test_notebooks.py | 6 +++++- view/Updates_rss.py | 10 ++++++++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4854d65..8d9aa0b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +1.3.38: May 26, 2008 + * Attempting to access the RSS feed for a non-existent notebook now + displays a somewhat informative message in the feed instead of just + silently raising an error. + 1.3.37: May 20, 2008 * Fixed a bug where image preloading loaded incorrect paths for certain images. diff --git a/controller/Notebooks.py b/controller/Notebooks.py index 73e2038..e620e82 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -248,7 +248,12 @@ class Notebooks( object ): """ notebook = self.__database.load( Notebook, notebook_id ) if not notebook: - raise Access_error() + return dict( + recent_notes = [], + notebook_id = notebook_id, + notebook_name = notebook_name, + https_url = self.__https_url, + ) recent_notes = self.__database.select_many( Note, notebook.sql_load_notes( start = 0, count = 10 ) ) diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py index b927c9a..75bc5fb 100644 --- a/controller/test/Test_notebooks.py +++ b/controller/test/Test_notebooks.py @@ -904,7 +904,11 @@ class Test_notebooks( Test_controller ): "/notebooks/updates/%s?rss¬ebook_name=%s" % ( self.unknown_notebook_id, self.notebook.name ), ) - assert u"access" in result[ "body" ][ 0 ] + # should return no notes (and not raise an error) + assert len( result[ u"recent_notes" ] ) == 0 + assert result[ u"notebook_id" ] == self.unknown_notebook_id + assert result[ u"notebook_name" ] == self.notebook.name + assert result[ u"https_url" ] == self.settings[ u"global" ][ u"luminotes.https_url" ] def test_updates_with_incorrect_notebook_name( self ): result = self.http_get( diff --git a/view/Updates_rss.py b/view/Updates_rss.py index 1b04e94..ca433ca 100644 --- a/view/Updates_rss.py +++ b/view/Updates_rss.py @@ -28,13 +28,19 @@ class Updates_rss( Rss_channel ): cgi.escape( notebook_name ), notebook_path, u"Luminotes notebook", - [ Rss_item( + recent_notes and [ Rss_item( title = u"Note updated", link = self.note_link( notebook_id, notebook_name, note_id, revision, https_url ), description = cgi.escape( u'A note in this notebook has been updated. View the note.' % ( notebook_path, notebook_path, note_id ) ), date = revision.strftime( "%Y-%m-%dT%H:%M:%SZ" ), guid = self.note_link( notebook_id, notebook_name, note_id, revision, https_url ), - ) for ( note_id, revision ) in recent_notes ], + ) for ( note_id, revision ) in recent_notes ] or [ Rss_item( + title = u"Unknown notebook", + link = None, + description = cgi.escape( u'Sorry, that notebook is unknown.' ), + date = None, + guid = None, + ) ], ) @staticmethod