ContentProviderLookupError: plone.htmlhead

UPDATE: jjmojojjmojo was kind enough to write a test for this bug, so hopefully the patch will show up in the next release.  See the bug if you would like the doctest.

—————————————————————————————————————————————

I have a BrowserView on an Archetypes type that I created. When I try to go to the view, I get the error ContentProviderLookupError: plone.htmlhead.

I found a bug report at https://bugs.launchpad.net/zope2/+bug/176566 There is a patch suggested there, but it looks like the patch may not be applied without a unit test. I have yet to be able to figure out how to test views, and I don’t like the idea of altering my Zope code. So, I wrote a monkey patch on my view that takes care of this.

view.py

from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile

def _getContext(self):
    while 1:
        self = self.aq_parent
        if not getattr(self, '_is_wrapperish', None):
            return self

class MyView(BrowserView):
    def __init__(self, context, request):
        self.context = context
        self.request = request
        #Monkey patch for weird error
        ZopeTwoPageTemplateFile._getContext = _getContext

~ by Liz on January 8, 2008.

4 Responses to “ContentProviderLookupError: plone.htmlhead”

  1. hey liz, thanks for posting this. this post just allowed me to come home in time for dinner instead of banging my head against the desk all evening at the office[1] ;-)

    cheers,

    Tom

    p.s. : you really should submit your blog to planet plone! [2]

    [1] http://twitter.com/tomlazar/statuses/677421402
    [2] http://planet.plone.org/

  2. I got bit by the same bug this week, and I wrote a unit test for it, which I posted to the bug page.

    https://bugs.launchpad.net/zope2/+bug/176566

    Hopefully that’ll help get it fixed for good.

  3. I got this error as well when using getMultiAdaper in a doctest. Accessing the view like this :

    view = portal.restrictedTraverse(’@@my-view’)

    does not give this error

  4. The bug report in question seems to be invalid, I think this patch hides the real error. You do not get this error because you use a BrowserView on an Archetypes object, there must be something else involved.

Leave a Reply