ippe
ippe

Reputation: 21

Creating a Plone 4 custom portlet manager

I am trying to create a custom portlet manager to my theme's footer by following tutorials from Plone.org and WebLion.

What I am trying to do is adding a viewlet manager and a viewlet, that should be functioning as the portlet manager, into my theme.

I am getting a ContentProviderLookupError for the viewlet that is supposed to work as my portlet manager when the viewlet's template has a TAL-block in it. The viewletmanager and viewlet template is shown correctly on the page as far as I can tell if I omit the TAL-block.

The theme is done using the sane_plone_addon_template from here

I really cant see what I am doing wrong here and being a complete noob when it comes to Plone really doesn't help, so any ideas to nudge me in the right direction would really be appreciated.

Heres my configure.zcml

<browser:viewletManager
         name="footerPortlets1"
         provides=".interfaces.IspFooterPortletsViewletManager"
         class="plone.app.viewletmanager.manager.OrderedViewletManager"
         layer=".interfaces.IThemeSpecific"
         permission="zope2.View"
    />

<browser:viewlet
        name="footerPortlets"
        manager=".interfaces.IspFooterPortletsViewletManager"
        template="templates/footerPortlets.pt"
        layer=".interfaces.IThemeSpecific"
        permission="zope2.View" 
    /> 

portlets.xml in profiles/default/

    <?xml version="1.0"?>
<portlets
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    i18n:domain="plone">

     <portletmanager 
       name="footerPortlets"
       type="mytheme.interfaces.IFooterPortlets"
     />

</portlets>

interfaces.py

from plone.portlets.interfaces import IPortletManager
from plone.app.portlets.interfaces import IColumn

class IFooterPortlets(IPortletManager, IColumn):
     """"""

heres the viewlet template footerPortlets.pt

<div id = "footer-portlets-container">
  test
  <tal:block replace="structure provider:footerPortlets" /> <!-- This part fails -->
</div>

And here's the stacktrace for the error:

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 237, in _exec
  Module Products.CMFCore.FSPageTemplate, line 177, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 888, in do_useMacro
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 531, in do_optTag_tal
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 218, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/home/user/Plone/zinstance/src/santasport/santasport/templates/plonetheme.sunburst.skins.sunburst_templates.main_template.pt
   - Line 181, Column 3
   - Expression: <StringExpr u'footerPortlets1'>
   - Names:
      {'container': <ATDocument at /Santasport/front-page>,
       'context': <ATDocument at /Santasport/front-page>,
       'default': <object object at 0xb77bc7d0>,
       'here': <ATDocument at /Santasport/front-page>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xb4a8e34c>,
       'request': <HTTPRequest, URL=http://127.0.0.1:8080/Santasport/front-page/document_view>,
       'root': <Application at >,
       'template': <FSPageTemplate at /Santasport/front-page/document_view>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>}
  Module zope.contentprovider.tales, line 80, in __call__
  Module plone.app.viewletmanager.manager, line 154, in render
  Module plone.app.viewletmanager.manager, line 85, in render
  Module zope.browserpage.simpleviewclass, line 44, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 531, in do_optTag_tal
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 218, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: /home/user/Plone/zinstance/src/santasport/santasport/templates/footerPortlets.pt
   - Line 3, Column 1
   - Expression: <StringExpr u'footerportlets'>
   - Names:
      {'args': (),
       'container': <ATDocument at /my-theme/front-page>,
       'context': <ATDocument at /my-theme/front-page>,
       'default': <object object at 0xb77bc7d0>,
       'here': <ATDocument at /my-theme/front-page>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xb4a7dcfc>,
       'request': <HTTPRequest, URL=http://127.0.0.1:8080/my-theme/front-page/document_view>,
       'root': <Application at >,
       'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0xb5e055ac>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>,
       'view': <Products.Five.viewlet.viewlet.SimpleViewletClass from /home/user/Plone/zinstance/src/my-theme/my-theme/templates/footerPortlets.pt object at 0xb4a3f52c>,
       'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0xb5e2cdac>}
  Module zope.contentprovider.tales, line 66, in __call__
ContentProviderLookupError: footerPortlets

EDIT:

I got this code working somewhat by adding my viewlet to viewlets.xml and adding it to my profiles-folder (as one of the tutorials said FML), but I didn't really test it out any further but instead looked into Mikko's tutorial which worked for me out of the box really nicely.

Ps: Any ideas how to mark this question up?

Upvotes: 2

Views: 899

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1124558

You'll need to import the portlets.xml configuration.

The most direct way is via the portal_setup tool in the ZMI. Find your product name on the "Import" tab (in the Select Profile or Snapshot select box), then when the page has reloaded (shows 'Available Import Steps for "Name of your product profile"') you need to look up the Portlets import step in the list ("Import portlet managers, types, assignments and blacklistings"), tick it's box, and hit the "Import selected steps" button at the bottom.

The WebLion tutorial documented this a little vaguely as "The configuration is now complete. Uninstall your theme, restart Zope and reinstall your theme.". The Plone.org documentation appears to omit it entirely.

Upvotes: 1

Related Questions