From 0358a03d5bd77770ab028690c60c23fbfd53db21 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 6 Sep 2010 10:38:54 +0000 Subject: [PATCH] Fetch context for the comment view with "context = aq_inner(self.context)". This fixes a failing Plone 3 test. svn path=/plone.app.discussion/trunk/; revision=39678 --- plone/app/discussion/browser/comment.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plone/app/discussion/browser/comment.py b/plone/app/discussion/browser/comment.py index f08e930..2adff65 100644 --- a/plone/app/discussion/browser/comment.py +++ b/plone/app/discussion/browser/comment.py @@ -1,16 +1,27 @@ -from Acquisition import aq_parent +from Acquisition import aq_inner, aq_parent from Products.Five.browser import BrowserView class View(BrowserView): """Comment View. - Redirect from /path/to/object/++conversation++default/123456789 - to /path/to/object#comment-123456789. + When the view of a comment object is called directly, redirect to the + the page (content object) and the location (HTML-anchor) where the comment + has been posted. + + Redirect from the comment object URL + "/path/to/object/++conversation++default/123456789" to the content object + where the comment has been posted appended by an HTML anchor that points to + the comment "/path/to/object#comment-123456789". + + Context is the comment object. The parent of the comment object is the + conversation. The parent of the conversation is the content object where + the comment has been posted. """ def __call__(self): - comment_id = aq_parent(self).id + context = aq_inner(self.context) self.request.response.redirect( - aq_parent(aq_parent(aq_parent(self))).absolute_url() + - '#' + str(comment_id)) \ No newline at end of file + aq_parent(aq_parent(context)).absolute_url() + + '#' + str(context.id) + ) \ No newline at end of file