qSEOptimizer and Plone Documentation Center acting up? Here is the fix.

published Jan 28, 2009, last modified Jun 26, 2013

Those two Plone products seem to never get along. Here's a hot fix for Plone 3.0.x users that will make the excellent qSEOptimizer by QuintaGroup work just fine along with Plone Documentation Center (PHC) and Plone Software Center (PSC).

The bug

You've installed qSEOptimizer (version 1.5.1 or version 1.6.0), and now every visitor to your Plone Documentation Center documents experiences an error.  The details of the error are like this:

Site Error
 
An error was encountered while publishing this resource.
 
AttributeError
Sorry, a site error occurred.
 
Traceback (innermost last):
 
    * Module ZPublisher.Publish, line 202, in publish_module_standard
    * Module ZPublisher.Publish, line 150, in publish
    * Module plone.app.linkintegrity.monkey, line 21, in zpublisher_exception_hook_wrapper
    * Module Zope2.App.startup, line 221, in zpublisher_exception_hook
    * Module ZPublisher.Publish, line 119, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 42, in call_object
    * Module Shared.DC.Scripts.Bindings, line 313, in __call__
    * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
    * Module Products.CMFCore.FSPageTemplate, line 216, in _exec
    * Module Products.CacheSetup.patch_cmf, line 48, in FSPT_pt_render
    * Module Products.CacheSetup.patch_cmf, line 120, in PT_pt_render
    * Module zope.tal.talinterpreter, line 271, in __call__
    * Module zope.tal.talinterpreter, line 346, in interpret
    * Module zope.tal.talinterpreter, line 891, in do_useMacro
    * Module zope.tal.talinterpreter, line 346, in interpret
    * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
    * Module zope.tal.talinterpreter, line 521, in do_optTag
    * Module zope.tal.talinterpreter, line 516, in no_tag
    * Module zope.tal.talinterpreter, line 346, in interpret
    * Module zope.tal.talinterpreter, line 586, in do_setLocal_tal
    * Module zope.tales.tales, line 696, in evaluate
      URL: file:/opt/prod/zeocluster/parts/plone/CMFPlone/skins/plone_templates/main_template.pt
      Line 32, Column 4
      Expression: 
      Names:
 
      {'container': ,
       'context': ,
       'default': ,
       'here': ,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': ,
       'request': ,
       'root': ,
       'template': ,
       'traverse_subpath': [],
       'user': }
 
    * Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
      __traceback_info__: putils.listMetaTags(here).items()
    * Module PythonExpr, line 1, in 
    * Module Products.qSEOptimizer, line 79, in listMetaTags
    * Module Products.qSEOptimizer.adapters, line 23, in listKeywords
 
AttributeError: qSEO_Keywords (Also, the following error occurred while attempting to render the standard error message, please see the event log for full details: qSEO_Keywords)

Do not despair.  I've got your back.

The hotfix

Kindly engineered with the help of jl_ at the Plone chat channel.

  1. Locate the qSEOptimizer files on your server.
  2. Find the file named adapters.py and open it into a text editor.
  3. Find this text, around line 23:
    keywords = list(self.context.qSEO_Keywords())
  4. Nuke it.  Replace it with:
    try: keywords = list(self.context.qSEO_Keywords())
    except AttributeError: keywords = []
    Remember to stay at the same indentation level.
  5. That's it.  Restart your Zope application server.

Now, your qSEOptimizer should no longer bork out with horrible errors when people access your PHC documents.