Back to index

plone3  3.1.7
portlets.py
Go to the documentation of this file.
00001 from zope.deprecation import deprecate
00002 from interfaces import IKSSPlonePortletCommands
00003 from plone.portlets.interfaces import IPortletManager
00004 from plone.app.portlets.portlets.classic import Assignment
00005 from plone.portlets.interfaces import IPortletRenderer
00006 from zope import component
00007 
00008 from kss.core.kssview import CommandSet
00009 from zope.interface import implements
00010 
00011 # XXX: This is deprecated and will be removed in Plone 4.0. Use the 'plone'
00012 # command set instead.
00013 class KSSPortletCommands(CommandSet):
00014     implements(IKSSPlonePortletCommands)
00015 
00016     @deprecate("The 'plone-portlets' command set is deprecated and will be removed in Plone 4.0. "
00017                "Please use the 'plone' command set instead.")
00018     def reload_classic_portlet(self, css_selector, column,
00019                                template, portlet_macro='portlet'):
00020         context = self.context
00021         request = self.request
00022         view = self.view
00023         manager = component.getUtility(
00024             IPortletManager, name=column, context=context)
00025         assignment = Assignment(
00026             template=template, macro=portlet_macro)
00027 
00028         portlet = component.getMultiAdapter(
00029             (context, request, view, manager, assignment), IPortletRenderer)
00030         portlet = portlet.__of__(context)
00031 
00032         view.getCommandSet('core').replaceInnerHTML(css_selector, portlet.render())