Ugly hack that works around a "ContentProviderLookupError: plone.htmlhead" error caused by Zope 2 permissions. See https://bugs.launchpad.net/zope2/+bug/176566 for further details. This error occured on Plone 3.3.x only.

svn path=/plone.app.discussion/trunk/; revision=33275
This commit is contained in:
Timo Stollenwerk 2010-01-22 16:28:00 +00:00
parent 1a1c903086
commit 0b530a0a75
2 changed files with 19 additions and 0 deletions

View File

@ -2,6 +2,7 @@ from Acquisition import aq_inner, aq_parent
from Products.Five.browser import BrowserView from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
@ -11,6 +12,23 @@ from Products.statusmessages.interfaces import IStatusMessage
from plone.app.discussion.interfaces import IComment from plone.app.discussion.interfaces import IComment
# Begin ugly hack. It works around a ContentProviderLookupError: plone.htmlhead error caused by Zope 2 permissions.
# This error occured on Plone 3.3.x only!
#
# Source: http://athenageek.wordpress.com/2008/01/08/contentproviderlookuperror-plonehtmlhead/
# Bug report: https://bugs.launchpad.net/zope2/+bug/176566
#
def _getContext(self):
self = self.aq_parent
while getattr(self, '_is_wrapperish', None):
self = self.aq_parent
return self
ZopeTwoPageTemplateFile._getContext = _getContext
# End ugly hack.
class View(BrowserView): class View(BrowserView):
"""Moderation View """Moderation View
""" """

View File

@ -42,6 +42,7 @@ class ModerationViewTest(PloneTestCase):
request = self.app.REQUEST request = self.app.REQUEST
context = getattr(self.portal, 'doc1') context = getattr(self.portal, 'doc1')
self.view = View(context, request) self.view = View(context, request)
self.view.__of__(context)
self.portal.portal_workflow.setChainForPortalTypes( self.portal.portal_workflow.setChainForPortalTypes(
('Discussion Item',), 'comment_review_workflow') ('Discussion Item',), 'comment_review_workflow')
self.wf_tool = self.portal.portal_workflow self.wf_tool = self.portal.portal_workflow