def formAdd(self, form):
     "add a render object from the form"
     name = form.get('renderName', None)
     header = form.get('renderHeader', '')
     body = form.get('renderBody', '')
     footer = form.get('renderFooter', '')
     utility.addRender(self.getCompoundDoc(), name, header, body, footer)
예제 #2
0
 def formAdd(self, form):
     "add a render object from the form"
     name = form.get('renderName', None)
     header = form.get('renderHeader', '')
     body = form.get('renderBody', '')
     footer = form.get('renderFooter', '')
     utility.addRender(self.getCompoundDoc(), name, header, body, footer)
예제 #3
0
    def createRenderFromFilter(self, folder, displayName, display,
                               displayFilter):
        "create a render from a filter"
        temp = []
        cdoc = self.getCompoundDoc()
        dm = cdoc.DisplayManager
        profile = cdoc.profile
        filterName, filterObj = displayFilter
        try:
            renders = folder.renders
        except AttributeError:
            folder.manage_addProduct['OFSP'].manage_addFolder('renders')
            renders = folder.renders

        temp.append('Working with folder %s' % renders.absolute_url_path())

        wrapper = lambda x: x
        if filterObj.codetype == 'DTML':
            wrapper = utility.dtmlToScript

        headerData = filterObj.wrapperHeader
        if headerData in ('return context.standard_html_header()',
                          '<dtml-var standard_html_footer>'):
            headerPath = "standard_html_header"
        elif headerData == '':
            headerPath = ''
        else:
            scriptname = '%s_%s' % (displayName, 'header')
            renders.manage_addProduct['PythonScripts'].manage_addPythonScript(
                scriptname)
            script = getattr(renders, scriptname)
            script.ZPythonScript_edit('', wrapper(headerData))
            headerPath = script.absolute_url_path()

        bodyData = filterObj.code
        scriptname = displayName
        renders.manage_addProduct['PythonScripts'].manage_addPythonScript(
            scriptname)
        script = getattr(renders, scriptname)
        script.ZPythonScript_edit('', wrapper(bodyData))
        bodyPath = script.absolute_url_path()

        footerData = filterObj.wrapperFooter
        if footerData in ('return context.standard_html_footer()',
                          '<dtml-var standard_html_footer>'):
            footerPath = "standard_html_footer"
        elif footerData == '':
            footerPath = ''
        else:
            scriptname = '%s_%s' % (displayName, 'footer')
            renders.manage_addProduct['PythonScripts'].manage_addPythonScript(
                scriptname)
            script = getattr(renders, scriptname)
            script.ZPythonScript_edit('', wrapper(footerData))
            footerPath = script.absolute_url_path()

        utility.addRender(cdoc, displayName, headerPath, bodyPath, footerPath)

        if display.usage == 'view' and displayName == dm.defaultView:
            utility.setDefaultView(cdoc, displayName)
            dm.delObjects(['defaultView'])
        elif display.usage == 'edit' and displayName == dm.defaultEdit:
            utility.setDefaultEdit(cdoc, displayName)
            dm.delObjects(['defaultEdit'])

        cdoc.DisplayManager.delObjects([displayName])
        temp.append('Converted %s to a render' % displayName)
        return temp
예제 #4
0
 def createRenderFromFilter(self, folder, displayName, display, displayFilter):
     "create a render from a filter"
     temp = []
     cdoc = self.getCompoundDoc()
     dm = cdoc.DisplayManager
     profile = cdoc.profile
     filterName, filterObj = displayFilter
     try:
         renders = folder.renders
     except AttributeError:
         folder.manage_addProduct['OFSP'].manage_addFolder('renders')
         renders = folder.renders
         
     temp.append('Working with folder %s' % renders.absolute_url_path())
     
     wrapper = lambda x: x
     if filterObj.codetype == 'DTML':
         wrapper = utility.dtmlToScript
     
     headerData = filterObj.wrapperHeader
     if headerData in ('return context.standard_html_header()', '<dtml-var standard_html_footer>'):
         headerPath = "standard_html_header"
     elif headerData == '':
         headerPath = ''
     else:
         scriptname = '%s_%s' % (displayName, 'header')
         renders.manage_addProduct['PythonScripts'].manage_addPythonScript(scriptname)
         script = getattr(renders, scriptname)
         script.ZPythonScript_edit('', wrapper(headerData))
         headerPath = script.absolute_url_path()
     
     bodyData = filterObj.code
     scriptname = displayName
     renders.manage_addProduct['PythonScripts'].manage_addPythonScript(scriptname)
     script = getattr(renders, scriptname)
     script.ZPythonScript_edit('', wrapper(bodyData))
     bodyPath = script.absolute_url_path()
     
     footerData = filterObj.wrapperFooter
     if footerData in ('return context.standard_html_footer()', '<dtml-var standard_html_footer>'):
         footerPath = "standard_html_footer"
     elif footerData == '':
         footerPath = ''
     else:
         scriptname = '%s_%s' % (displayName, 'footer')
         renders.manage_addProduct['PythonScripts'].manage_addPythonScript(scriptname)
         script = getattr(renders, scriptname)
         script.ZPythonScript_edit('', wrapper(footerData))
         footerPath = script.absolute_url_path()
     
     utility.addRender(cdoc, displayName, headerPath, bodyPath, footerPath)
     
     if display.usage == 'view' and displayName == dm.defaultView:
         utility.setDefaultView(cdoc, displayName)
         dm.delObjects(['defaultView'])
     elif display.usage == 'edit' and displayName == dm.defaultEdit:
         utility.setDefaultEdit(cdoc, displayName)
         dm.delObjects(['defaultEdit'])
     
     
     cdoc.DisplayManager.delObjects([displayName])
     temp.append('Converted %s to a render' % displayName)
     return temp