Back to index

plone3  3.1.7
refreshprovider.py
Go to the documentation of this file.
00001 from zope.deprecation import deprecate
00002 from kss.core.kssview import CommandSet
00003 from zope.component import getMultiAdapter
00004 from zope.contentprovider.interfaces import IContentProvider
00005 
00006 # XXX: This is deprecated and will be removed in Plone 4.0. Use the 'zope'
00007 # command set instead.
00008 class RefreshProviderCommand(CommandSet):
00009     """Refreshes the selected provider (provides IContentProvider) named name and located
00010     at selector in the HTML"""
00011 
00012     @deprecate("The 'refreshprovider' command set is deprecated and will be removed in Plone 4.0. "
00013                "Please use the 'zope' command set instead.")
00014     def refreshProvider(self, name, selector):
00015         # Cleaned out all the old code pre-provider menus (supposed safe, we are in Plone 3.0)
00016         # Basically the code comes from jfroche's locking branch, where we get the provider
00017         # through adaptation and we render it. Right now a big refresh issue occurs on workflow
00018         # state changes
00019         contentMenuProvider = getMultiAdapter((self.context, self.request, self.view),
00020                                               IContentProvider,
00021                                               name=name)
00022         renderer = contentMenuProvider.__of__(self.context)
00023         renderer.update()
00024         result = renderer.render()
00025         # Command the replacement
00026         ksscore = self.getCommandSet('core')
00027         # Here we are using a replaceInner because we are binding to a selector to do that:
00028         # in case the provider does not want to be shown (and we have an example with the contentmenu
00029         # in edit tab) then the renderer might return a blank string, if we replace that normally then we
00030         # won't have selectors to get back!
00031         ksscore.replaceInnerHTML(ksscore.getCssSelector(selector), result)
00032