From 43d926ed94f4486ff18206216ddffa86ff2b027c Mon Sep 17 00:00:00 2001 From: Sebastian Dietrich Date: Sat, 13 Jan 2018 19:41:15 +0100 Subject: [PATCH] Avoid errors when attachment name contains non-ASCII characters. --- code_comments/subscription.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code_comments/subscription.py b/code_comments/subscription.py index cbe14dc..ec4650c 100644 --- a/code_comments/subscription.py +++ b/code_comments/subscription.py @@ -54,7 +54,7 @@ def select(cls, env, args={}, notify=None): """ Retrieve existing subscription(s). """ - select = 'SELECT * FROM code_comments_subscriptions' + select = u'SELECT * FROM code_comments_subscriptions' if notify: args['notify'] = bool(notify) @@ -63,16 +63,16 @@ def select(cls, env, args={}, notify=None): select += ' WHERE ' criteria = [] for key, value in args.iteritems(): - template = '{0}={1}' + template = u'{0}={1}' if isinstance(value, basestring): - template = '{0}=\'{1}\'' + template = u'{0}=\'{1}\'' if (isinstance(value, tuple) or isinstance(value, list)): - template = '{0} IN (\'{1}\')' - value = '\',\''.join(value) + template = u'{0} IN (\'{1}\')' + value = u'\',\''.join(value) if isinstance(value, bool): value = int(value) criteria.append(template.format(key, value)) - select += ' AND '.join(criteria) + select += u' AND '.join(criteria) for row in env.db_query(select): yield cls._from_row(env, row) @@ -188,7 +188,7 @@ def from_attachment(cls, env, attachment, user=None, notify=True): """ Creates a subscription from an Attachment object. """ - _path = "/{0}/{1}/{2}".format(attachment.parent_realm, + _path = u"/{0}/{1}/{2}".format(attachment.parent_realm, attachment.parent_id, attachment.filename)