Skip to content

fix issue #62 #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions code_comments/subscription.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
from code_comments.api import ICodeCommentChangeListener
from code_comments.comments import Comments


class Subscription(object):
"""
Representation of a code comment subscription.
@@ -87,11 +86,12 @@ def insert(self, db=None):
@self.env.with_transaction()
def do_insert(db):
cursor = db.cursor()
insert = ("INSERT INTO code_comments_subscriptions "
"(user, type, path, repos, rev, notify) "
"VALUES (%s, %s, %s, %s, %s, %s)")
insert = (u"INSERT INTO code_comments_subscriptions "
u"(user, type, path, repos, rev, notify) "
u"VALUES (%s, %s, %s, %s, %s, %s)")
self.path = self.path.decode('utf8')
values = (self.user, self.type, self.path, self.repos,
self.rev, self.notify)
self.rev, self.notify)
cursor.execute(insert, values)
self.id = db.get_last_id(cursor, 'code_comments_subscriptions')
return True
@@ -107,9 +107,10 @@ def update(self, db=None):
@self.env.with_transaction()
def do_update(db):
cursor = db.cursor()
update = ("UPDATE code_comments_subscriptions SET "
"user=%s, type=%s, path=%s, repos=%s, rev=%s, "
"notify=%s WHERE id=%s")
update = (u"UPDATE code_comments_subscriptions SET "
u"user=%s, type=%s, path=%s, repos=%s, rev=%s, "
u"notify=%s WHERE id=%s")
self.path = self.path.encode('utf8')
values = (self.user, self.type, self.path, self.repos,
self.rev, self.notify, self.id)
try:
@@ -131,6 +132,8 @@ def do_delete(db):
"id=%s")
cursor.execute(delete, (self.id,))



@classmethod
def _from_row(cls, env, row):
"""
@@ -193,10 +196,14 @@ 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,

filename = attachment.filename

_path = u"/{0}/{1}/{2}".format(attachment.parent_realm,
attachment.parent_id,
attachment.filename)

filename)
_path = _path.encode('utf8')

sub = {
'user': user or attachment.author,
'type': 'attachment',
@@ -265,10 +272,13 @@ def for_attachment(cls, env, attachment, path=None, notify=None):
Returns all subscriptions for an attachment. The path can be
overridden.
"""
path_template = "/{0}/{1}/{2}"
path_template = u"/{0}/{1}/{2}"
filename = attachment.filename
_path = path or path_template.format(attachment.parent_realm,
attachment.parent_id,
attachment.filename)
filename)
_path = _path.encode('utf8')

args = {
'type': 'attachment',
'path': _path,
@@ -418,13 +428,17 @@ def attachment_deleted(self, attachment):

def attachment_reparented(self, attachment, old_parent_realm,
old_parent_id):
path_template = "/{0}/{1}/{2}"
path_template = u"/{0}/{1}/{2}"
filename = attachment.filename
old_path = path_template.format(old_parent_realm,
old_parent_id,
attachment.filename)
filename)
old_path = old_path.encode('utf8')

new_path = path_template.format(attachment.parent_realm,
attachment.parent_id,
attachment.filename)
filename)
new_path = new_path.encode('utf8')

for subscription in Subscription.for_attachment(self.env, attachment,
old_path):