Browse Source

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.
Dan Helfman 10 years ago
parent
commit
e971959755
4 changed files with 24 additions and 4 deletions
  1. 5
    0
      NEWS
  2. 6
    1
      controller/Notebooks.py
  3. 5
    1
      controller/test/Test_notebooks.py
  4. 8
    2
      view/Updates_rss.py

+ 5
- 0
NEWS View File

@@ -1,3 +1,8 @@
1
+1.3.38: May 26, 2008
2
+ * Attempting to access the RSS feed for a non-existent notebook now
3
+   displays a somewhat informative message in the feed instead of just
4
+   silently raising an error.
5
+
1 6
 1.3.37: May 20, 2008
2 7
  * Fixed a bug where image preloading loaded incorrect paths for
3 8
    certain images.

+ 6
- 1
controller/Notebooks.py View File

@@ -248,7 +248,12 @@ class Notebooks( object ):
248 248
     """
249 249
     notebook = self.__database.load( Notebook, notebook_id )
250 250
     if not notebook:
251
-      raise Access_error()
251
+      return dict(
252
+        recent_notes = [],
253
+        notebook_id = notebook_id,
254
+        notebook_name = notebook_name,
255
+        https_url = self.__https_url,
256
+      )
252 257
 
253 258
     recent_notes = self.__database.select_many( Note, notebook.sql_load_notes( start = 0, count = 10 ) )
254 259
 

+ 5
- 1
controller/test/Test_notebooks.py View File

@@ -904,7 +904,11 @@ class Test_notebooks( Test_controller ):
904 904
       "/notebooks/updates/%s?rss&notebook_name=%s" % ( self.unknown_notebook_id, self.notebook.name ),
905 905
     )
906 906
 
907
-    assert u"access" in result[ "body" ][ 0 ]
907
+    # should return no notes (and not raise an error)
908
+    assert len( result[ u"recent_notes" ] ) == 0
909
+    assert result[ u"notebook_id" ] == self.unknown_notebook_id
910
+    assert result[ u"notebook_name" ] == self.notebook.name
911
+    assert result[ u"https_url" ] == self.settings[ u"global" ][ u"luminotes.https_url" ]
908 912
 
909 913
   def test_updates_with_incorrect_notebook_name( self ):
910 914
     result = self.http_get(

+ 8
- 2
view/Updates_rss.py View File

@@ -28,13 +28,19 @@ class Updates_rss( Rss_channel ):
28 28
       cgi.escape( notebook_name ),
29 29
       notebook_path,
30 30
       u"Luminotes notebook",
31
-      [ Rss_item(
31
+      recent_notes and [ Rss_item(
32 32
         title = u"Note updated",
33 33
         link = self.note_link( notebook_id, notebook_name, note_id, revision, https_url ),
34 34
         description = cgi.escape( u'A note in <a href="%s">this notebook</a> has been updated. <a href="%s?note_id=%s">View the note.</a>' % ( notebook_path, notebook_path, note_id ) ),
35 35
         date = revision.strftime( "%Y-%m-%dT%H:%M:%SZ" ),
36 36
         guid = self.note_link( notebook_id, notebook_name, note_id, revision, https_url ),
37
-      ) for ( note_id, revision ) in recent_notes ],
37
+      ) for ( note_id, revision ) in recent_notes ] or [ Rss_item(
38
+        title = u"Unknown notebook",
39
+        link = None,
40
+        description = cgi.escape( u'Sorry, that notebook is unknown.' ),
41
+        date = None,
42
+        guid = None,
43
+      ) ],
38 44
     )
39 45
 
40 46
   @staticmethod

Loading…
Cancel
Save