Obey the 80 chars limit in the migration function.

svn path=/plone.app.discussion/trunk/; revision=39331
This commit is contained in:
Timo Stollenwerk 2010-08-28 20:18:36 +00:00
parent 632e167806
commit 785b006394

View File

@ -65,8 +65,10 @@ class View(BrowserView):
comment.text = reply.text comment.text = reply.text
comment.creator = reply.Creator() comment.creator = reply.Creator()
comment.creation_date = datetime.fromtimestamp(reply.creation_date) comment.creation_date = datetime.fromtimestamp(
comment.modification_date = datetime.fromtimestamp(reply.modification_date) reply.creation_date)
comment.modification_date = datetime.fromtimestamp(
reply.modification_date)
comment.reply_to = in_reply_to comment.reply_to = in_reply_to
@ -83,7 +85,10 @@ class View(BrowserView):
# migrate all talkbacks of the reply # migrate all talkbacks of the reply
talkback = getattr( reply, 'talkback', None ) talkback = getattr( reply, 'talkback', None )
no_replies_left = migrate_replies(context, new_in_reply_to, talkback.getReplies(), depth=depth+1) no_replies_left = migrate_replies(context,
new_in_reply_to,
talkback.getReplies(),
depth=depth+1)
if no_replies_left: if no_replies_left:
# remove reply and talkback # remove reply and talkback
talkback.deleteReply(reply.id) talkback.deleteReply(reply.id)
@ -92,7 +97,8 @@ class View(BrowserView):
log("%sremove %s" % (indent, reply.id)) log("%sremove %s" % (indent, reply.id))
self.total_comments_deleted += 1 self.total_comments_deleted += 1
# Return True when all comments on a certain level have been migrated. # Return True when all comments on a certain level have been
# migrated.
return True return True
# Find content # Find content
@ -100,9 +106,13 @@ class View(BrowserView):
object_provides='Products.CMFCore.interfaces._content.IContentish') object_provides='Products.CMFCore.interfaces._content.IContentish')
log("Found %s content objects." % len(brains)) log("Found %s content objects." % len(brains))
count_discussion_items = len(catalog.searchResults(Type='Discussion Item')) count_discussion_items = len(catalog.searchResults(
count_comments_pad = len(catalog.searchResults(object_provides=IComment.__identifier__)) Type='Discussion Item'))
count_comments_old = len(catalog.searchResults(object_provides=IDiscussionResponse.__identifier__)) count_comments_pad = len(catalog.searchResults(
object_provides=IComment.__identifier__))
count_comments_old = len(catalog.searchResults(
object_provides=IDiscussionResponse.\
__identifier__))
log("Found %s Discussion Item objects." % count_discussion_items) log("Found %s Discussion Item objects." % count_discussion_items)
log("Found %s old discussion items." % count_comments_old) log("Found %s old discussion items." % count_comments_old)
@ -128,14 +138,16 @@ class View(BrowserView):
if replies: if replies:
conversation = IConversation(obj) conversation = IConversation(obj)
log("\n") log("\n")
log("Migrate '%s' (%s)" % (obj.Title(), obj.absolute_url(relative=1))) log("Migrate '%s' (%s)" % (obj.Title(),
obj.absolute_url(relative=1)))
migrate_replies(context, 0, replies) migrate_replies(context, 0, replies)
obj = aq_parent(talkback) obj = aq_parent(talkback)
obj.talkback = None obj.talkback = None
if self.total_comments_deleted != self.total_comments_migrated: if self.total_comments_deleted != self.total_comments_migrated:
log("Something went wrong during migration. The number of migrated comments (%s)\ log("Something went wrong during migration. The number of \
differs from the number of deleted comments (%s)." migrated comments (%s) differs from the number of deleted \
comments (%s)."
% (self.total_comments_migrated, self.total_comments_deleted)) % (self.total_comments_migrated, self.total_comments_deleted))
if not test: if not test:
transaction.abort() transaction.abort()
@ -149,7 +161,8 @@ class View(BrowserView):
% (self.total_comments_migrated, count_comments_old)) % (self.total_comments_migrated, count_comments_old))
if self.total_comments_migrated != count_comments_old: if self.total_comments_migrated != count_comments_old:
log("%s comments could not be migrated." % (count_comments_old - self.total_comments_migrated)) log("%s comments could not be migrated."
% (count_comments_old - self.total_comments_migrated))
log("Please make sure your portal catalog is up-to-date.") log("Please make sure your portal catalog is up-to-date.")
if dry_run and not test: if dry_run and not test: