Skip to content

Commit

Permalink
Avoid errors when attachment name contains non-ASCII characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebDieBln committed Sep 22, 2019
1 parent 3d99bf6 commit 24e4a16
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions code_comments/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 24e4a16

Please sign in to comment.