Back to index

plone3  3.1.7
zopecommands.py
Go to the documentation of this file.
00001 from zope.interface import implements
00002 from zope.component import getMultiAdapter
00003 
00004 from zope.contentprovider.interfaces import IContentProvider
00005 from zope.viewlet.interfaces import IViewletManager
00006 from zope.viewlet.interfaces import IViewlet
00007 
00008 from kss.core import CommandSet
00009 from interfaces import IZopeCommands
00010 
00011 class ZopeCommands(CommandSet):
00012     implements(IZopeCommands)
00013     
00014     def refreshProvider(self, selector, name):
00015         provider = getMultiAdapter((self.context, self.request, self.view),
00016                                     IContentProvider, name=name)
00017         renderer = provider.__of__(self.context)
00018         
00019         renderer.update()
00020         result = renderer.render()
00021 
00022         ksscore = self.getCommandSet('core')
00023         ksscore.replaceHTML(selector, result)
00024     
00025     def refreshViewlet(self, selector, manager, name):
00026         
00027         if isinstance(manager, basestring):
00028             manager = getMultiAdapter((self.context, self.request, self.view,),
00029                                       IViewletManager, name=manager)
00030         
00031         renderer = getMultiAdapter((self.context, self.request, self.view, manager),
00032                                    IViewlet, name=name)
00033         renderer = renderer.__of__(self.context)
00034         
00035         renderer.update()
00036         result = renderer.render()
00037         
00038         ksscore = self.getCommandSet('core')
00039         ksscore.replaceHTML(selector, result)