示例#1
0
 def moveViewletToViewletManager(self, viewlethash, toManagerName):
     """ Register the viewlet as belonging to the specified viewlet manager """
     # Unhash the viewlet info. Pull out what we need.
     unhashedInfo = unhashViewletInfo(viewlethash)
     fromManagerName = unhashedInfo['managerName']
     viewletName = unhashedInfo['viewletName']
     
     reg = findTemplateViewRegistrationFromHash(viewlethash)
     
     fromViewletManager = queryMultiAdapter((self.context, self.request, self), IViewletManager, fromManagerName)
     fromManagerInterface = list(providedBy(fromViewletManager).flattened())[0]
     toViewletManager = queryMultiAdapter((self.context, self.request, self), IViewletManager, toManagerName)
     toManagerInterface = list(providedBy(toViewletManager).flattened())[0]
     
     # Create a new tuple of the "required" interfaces.
     reqList = list(reg.required)
     pos = reqList.index(fromManagerInterface)
     reqList[pos] = toManagerInterface
     reqs = tuple(reqList)
     
     registration.createTTWViewTemplate(reg)
     attr, pt = findViewletTemplate(reg.factory)
     reg.factory.template = mangleAbsoluteFilename(pt.filename)
     
     # Register the new adapter
     gsm = getGlobalSiteManager()
     gsm.registerAdapter(name=viewletName, required=reqs, provided=reg.provided, factory=reg.factory)
     
     # "Customize" it to force persistence
     reqstr = ','.join([a.__identifier__ for a in reqs])
     toreg = registration.findTemplateViewRegistration(reqstr, viewletName)
     viewzpt = registration.customizeTemplate(toreg)
     
     sm = getSiteManager(self.context)
     sm.registerAdapter(viewzpt, required=toreg.required, provided=toreg.provided, name=toreg.name)
     
     # Hide the original
     self.hideViewlet(viewlethash)
     
     # Rerender the new one
     # We can't do this with a refreshProvider call because then we lose the <tal:viewletmanager> block.
     toViewletManager.update()
     ksscore = self.getCommandSet('core')
     selector = ksscore.getCssSelector('.kssattr-viewletmanagername-' + toManagerName.replace('.', '-'))
     ksscore.replaceInnerHTML(selector, toViewletManager.render())
     
     # Inspect the new viewlet
     return self.inspectViewlet(hashViewletInfo(viewletName, toManagerName, unhashedInfo['provided']))
示例#2
0
 def getRegistrationFromRequest(self):
     form = self.request.form
     return registration.findTemplateViewRegistration(form['required'],
                                                      form['view_name'])
示例#3
0
 def getRegistrationFromRequest(self):
     form = self.request.form
     return registration.findTemplateViewRegistration(
         form['required'], form['view_name'])
示例#4
0
def findTemplateViewRegistrationFromHash(hash):
    """ Get the view registration information from plone.app.customerize """
    unhashedInfo = unhashViewletInfo(hash)
    return registration.findTemplateViewRegistration(unhashedInfo["provided"], unhashedInfo["viewletName"])