Esempio n. 1
0
    def manage_customizeForm(self, name, REQUEST=None):
        """ Copy the form from disk to zodb """
        body = self.template_content(name)
        ob = Template(id=name, title=name, text=body, content_type='text/html')
        ob._naaya_original_text = body
        self._setObject(name, ob)

        if REQUEST is not None:
            return REQUEST.RESPONSE.redirect('%s/%s/manage_workspace' %
                                             (self.absolute_url(), name))
Esempio n. 2
0
    def manage_customizeForm(self, name, REQUEST=None):
        """ Copy the form from disk to zodb """
        body = self.template_content(name)
        ob = Template(id=name, title=name, text=body,
                content_type='text/html')
        ob._naaya_original_text = body
        self._setObject(name, ob)

        if REQUEST is not None:
            return REQUEST.RESPONSE.redirect('%s/%s/manage_workspace' %
                                             (self.absolute_url(), name))
Esempio n. 3
0
    def manage_customizeForm(self, form_id, REQUEST=None):
        """ Copy the form from disk to zodb """
        for form in self.listDefaultForms():
            if form["id"] == form_id:
                if "form_ob" in form:
                    body = form["form_ob"]._text
                else:
                    body = self.futRead(form["path"], "r")
                break
        else:
            raise KeyError('Not found form named "%s"' % form_id)

        ob = Template(id=form["id"], title=form["title"], text=body, content_type="text/html")
        ob._naaya_original_text = body
        self._setObject(form["id"], ob)

        if REQUEST is not None:
            return REQUEST.RESPONSE.redirect("%s/%s/manage_workspace" % (self.absolute_url(), form["id"]))
Esempio n. 4
0
    def getForm(self, form_id):
        """
        Fetches a Naaya form

        First looks in the portal_forms folder (in case the form has been
        customized). If not, then it looks for default templates in packages.
        """
        if form_id in self.objectIds():
            return self._getOb(form_id)
        else:
            for form in self.listDefaultForms():
                if form['id'] == form_id:
                    if 'form_ob' in form:
                        return form['form_ob'].__of__(self)

                    body=self.futRead(form['path'], 'r')
                    t = Template(id=form['id'],
                                 title=form['title'],
                                 text=body,
                                 content_type='')
                    return t.__of__(self)
            raise KeyError('Not found form named "%s"' % form_id)
Esempio n. 5
0
    def test_lookup_custom_index(self):
        folder = self.folder

        # initially, nothing is set
        assert folder.get_custom_index_template() is None
        assert folder.compute_custom_index_value() == ''

        # test old-style `publicinterface` property
        folder.publicinterface = 1
        assert folder.compute_custom_index_value() == 'local:index'
        assert folder.get_custom_index_template() is None
        manage_addPageTemplate(folder, id='index', title='', text="hello1")
        transaction.commit()
        assert folder.get_custom_index_template() == folder.index
        self.browser.go('http://localhost/portal/info/testfolder')
        assert self.browser.get_html().strip() == "hello1"

        # new-style custom_index, locally in folder
        manage_addPageTemplate(folder, id='something', title='', text="hello2")
        folder.custom_index = 'local:something'
        assert folder.compute_custom_index_value() == 'local:something'
        transaction.commit()
        assert folder.get_custom_index_template() == folder.something
        self.browser.go('http://localhost/portal/info/testfolder')
        assert self.browser.get_html().strip() == "hello2"

        # new-style custom_index, in portal_forms
        portal_forms = self.portal.portal_forms
        portal_forms._setObject('something-else',
                        Template(id='something-else', title="",
                                 text="hello3", content_type='text/html'))
        folder.custom_index = 'site:portal_forms/something-else'
        assert (folder.compute_custom_index_value() ==
                'site:portal_forms/something-else')
        transaction.commit()
        assert (folder.get_custom_index_template() ==
                portal_forms['something-else'])
        self.browser.go('http://localhost/portal/info/testfolder')
        assert self.browser.get_html().strip() == "hello3"
Esempio n. 6
0
 def test_Text(self):
     tpl = Template('uid', 'title', 'AMD/Cyron', 'text/html')
     self.assertEqual(tpl.getText(), 'AMD/Cyron')
Esempio n. 7
0
 def test_Path(self):
     tpl = Template('uid', 'title', 'text', 'text/html')
     self.assertEqual(tpl.getPath(), None)
     tpl.setPath('testx')
     self.assertEqual(tpl.getPath(), 'testx')
Esempio n. 8
0
 def test_Customized(self):
     tpl = Template('uid', 'title', 'text', 'text/html')
     self.assertEqual(tpl.isCustomized(), False)
     tpl.setCustomized(True)
     self.assertEqual(tpl.isCustomized(), True)