Commits

Ethan Jucovy  committed d65f393

those stream[1][1]s are not robust enough

  • Participants
  • Parent commits b6e7a11

Comments (0)

Files changed (1)

File userpictures/__init__.py

 
     def _browser_lineitem_filter(self, req, data):
         def find_change(stream):
-            author = stream[1][1]
+            author = ''.join(stream_part[1] for stream_part in stream if stream_part[0] == 'TEXT').strip()
             tag = self._generate_avatar(req, author,
                                         'browser-lineitem', self.browser_lineitem_size)
             return itertools.chain([stream[0]], tag, stream[1:])
         if 'results' not in data:
             return []
 
+        ## The stream contains this stupid "By ethan" instead of just "ethan"
+        ## so we'll rely on the ordering of the data instead, 
+        ## and file a ticket with Trac core eventually
+        results_iter = iter(data['results'])
         def find_change(stream):
-            author = stream[1][1]
+            try:
+                author = results_iter.next()['author']
+            except StopIteration:
+                author = ''.join(stream_part[1] for stream_part in stream if stream_part[0] == 'TEXT').strip() ## As a fallback, we may as well, but this should never happen...
             tag = self._generate_avatar(req, author,
                                         'search-results', 
                                         self.search_results_size)
             class_ = 'report'
 
         def find_change(stream):
-            author = stream[1][1]
+            author = ''.join(stream_part[1] for stream_part in stream if stream_part[0] == 'TEXT').strip()
             tag = self._generate_avatar(req, author,
                                         class_, self.report_size)
             return itertools.chain([stream[0]], tag, stream[1:])
     
     def _wiki_history_lineitem_filter(self, req, data):
         def find_change(stream):
-            author = stream[1][1]
+            author = ''.join(stream_part[1] for stream_part in stream if stream_part[0] == 'TEXT').strip()
             tag = self._generate_avatar(req, author,
                                         'wiki-history-lineitem', self.wiki_history_lineitem_size)
             return itertools.chain([stream[0]], tag, stream[1:])
 
     def _page_attachments_filter(self, req, data):
         def find_change(stream):
-            author = stream[1][1]
+            author = ''.join(stream_part[1] for stream_part in stream if stream_part[0] == 'TEXT').strip()
             tag = self._generate_avatar(req, author,
                                         'attachment-lineitem', self.attachment_lineitem_size)
             return itertools.chain([stream[0]], tag, stream[1:])