def before_manage_edit(self, form=None):
        "This item is in charge of the profile/layout manager object"
        cdoc = self.getCompoundDoc()
        if 'addRender' in form:
            self.formAdd(form)
            del form['addRender']

        if 'render' in form:
            self.formEditRender(form)
            del form['render']

        if cdoc.displayMap is not None:
            if 'defaultEdit' in form:
                utility.setDefaultEdit(cdoc, form['defaultEdit'])
                del form['defaultEdit']
            if 'defaultView' in form:
                utility.setDefaultView(cdoc, form['defaultView'])
                del form['defaultView']

        if 'delete' in form:
            self.formDeleteRenders(form)
            del form['delete']
Exemplo n.º 2
0
    def before_manage_edit(self, form=None):
        "This item is in charge of the profile/layout manager object"
        cdoc = self.getCompoundDoc()
        if 'addRender' in form:
            self.formAdd(form)
            del form['addRender']

        if 'render' in form:
            self.formEditRender(form)
            del form['render']

        if cdoc.displayMap is not None:
            if 'defaultEdit' in form:
                utility.setDefaultEdit(cdoc, form['defaultEdit'])
                del form['defaultEdit']
            if 'defaultView' in form:
                utility.setDefaultView(cdoc, form['defaultView'])
                del form['defaultView']

        if 'delete' in form:
            self.formDeleteRenders(form)
            del form['delete']
Exemplo n.º 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
Exemplo n.º 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