Use unicode for logging comments
authorTryggvi Bjorgvinsson <tryggvib@fsfi.is>
Fri, 28 Feb 2014 23:25:02 +0000 (23:25 +0000)
committerJessica Tallon <jessica@megworld.co.uk>
Fri, 18 Jul 2014 14:27:35 +0000 (15:27 +0100)
The comment problems detailed in issue 791 are related to logging
of comments creation. The log tries to format unicode comments into
an ascii string (that is the unicode comment content).

This also creates problems with mark seen functionality since that
also logs the comments which breaks and you end up with a lot of
international comments in your message queue.

This commit makes both log messages unicode as well as the
representation of the comment.

mediagoblin/db/mixin.py
mediagoblin/db/models.py
mediagoblin/notifications/__init__.py
mediagoblin/notifications/task.py

index 048cc07cae84551e576ee3c0134399946025d02a..3d96ba34e61c895fb2458afb77f15c30dde4ca6b 100644 (file)
@@ -295,7 +295,7 @@ class MediaCommentMixin(object):
         return cleaned_markdown_conversion(self.content)
 
     def __repr__(self):
-        return '<{klass} #{id} {author} "{comment}">'.format(
+        return u'<{klass} #{id} {author} "{comment}">'.format(
             klass=self.__class__.__name__,
             id=self.id,
             author=self.get_author,
index 643d5d41ba3e7aa5068cf2dc0c05d5b0ea72358a..4c9345fc87b6507871fd4253c98b932e6ba338d8 100644 (file)
@@ -666,7 +666,7 @@ class Notification(Base):
     }
 
     def __repr__(self):
-        return '<{klass} #{id}: {user}: {subject} ({seen})>'.format(
+        return u'<{klass} #{id}: {user}: {subject} ({seen})>'.format(
             id=self.id,
             klass=self.__class__.__name__,
             user=self.user,
index b6f9f4789fe7c3da570d16a5c67a208e41001bd6..c7a9a1fb0f9328c93e486f28bb9fcc872260e7e6 100644 (file)
@@ -65,7 +65,7 @@ def mark_comment_notification_seen(comment_id, user):
         user_id=user.id,
         subject_id=comment_id).first()
 
-    _log.debug('Marking {0} as seen.'.format(notification))
+    _log.debug(u'Marking {0} as seen.'.format(notification))
 
     mark_notification_seen(notification)
 
index 52573b5779bb902c988a4bf3a7e13598ef840406..d915212afacc1a732fcd183fbb4ae7f1c25ff14a 100644 (file)
@@ -35,7 +35,7 @@ class EmailNotificationTask(Task):
     '''
     def run(self, notification_id, message):
         cn = CommentNotification.query.filter_by(id=notification_id).first()
-        _log.info('Sending notification email about {0}'.format(cn))
+        _log.info(u'Sending notification email about {0}'.format(cn))
 
         return send_email(
             message['from'],