예제 #1
0
    def portlets(self):
        '''
        Renders the first paragraph of all ghost objects and documents contained in the site root.
        '''
        view = self.context
        root = rw_layout.getLocalSite(view, self.request)
        portlets = []
        index = root.get_default()
        for portlet in root.get_ordered_publishables():            
            model = None
            if IGhost.providedBy(portlet):
                model = portlet.getLastVersion().get_haunted()
            elif IDocument.providedBy(portlet):
                model = portlet
            if not model: continue
            
            view.REQUEST.model = model
            version = model.get_viewable()
            content = None
            if version:
                content = self._renderVersion(version, portlet.get_title(), model.absolute_url())                
            if content:
                portlets.append(content)

        return portlets and portlets or []
예제 #2
0
    def test_document_link(self):
        """Try to import a document that contains a link.
        """
        importer = self.assertImportFile(
            'test_import_link.silvaxml',
            ['/root/folder/document',
             '/root/folder/site',
             '/root/folder'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(
            self.root.folder.objectIds(),
            ['document', 'site'])

        document = self.root.folder.document
        link = self.root.folder.site
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_viewable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_editable(), None)
        self.assertEqual(version.get_title(), 'Cool site')

        service = getUtility(IReferenceService)
        # Hopefully there is only one link in the document so this
        # should match the only link we have
        reference = service.get_reference(version, LINK_REFERENCE_TAG)
        self.assertFalse(reference is None)
        self.assertItemsEqual(
            list(service.get_references_from(version)), [reference])
        self.assertEqual(reference.target, link)

        self.assertDocumentEqual(
            version, 'test_imported_link.docxml',
            link_reference=reference.tags[1])

        # Test the document have been indexed. It is published so we
        # can search on the fulltext.
        catalog = getUtility(ICatalogService)
        results = catalog(fulltext="übber-cool site")
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].getObject(), version)
    def test_document_link(self):
        """Try to import a document that contains a link.
        """
        importer = self.assertImportFile(
            'test_import_link.silvaxml',
            ['/root/folder/document',
             '/root/folder/site',
             '/root/folder'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(
            self.root.folder.objectIds(),
            ['document', 'site'])

        document = self.root.folder.document
        link = self.root.folder.site
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_viewable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_editable(), None)
        self.assertEqual(version.get_title(), u'Cool site')

        service = getUtility(IReferenceService)
        # Hopefully there is only one link in the document so this
        # should match the only link we have
        reference = service.get_reference(version, LINK_REFERENCE_TAG)
        self.assertFalse(reference is None)
        self.assertItemsEqual(
            list(service.get_references_from(version)), [reference])
        self.assertEqual(reference.target, link)

        self.assertDocumentEqual(
            version, 'test_imported_link.docxml',
            link_reference=reference.tags[1])

        # Test the document have been indexed. It is published so we
        # can search on the fulltext.
        catalog = getUtility(ICatalogService)
        results = catalog(fulltext=u"übber-cool site")
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].getObject(), version)
예제 #4
0
    def test_document_image(self):
        """Try to import a document that contains an image.
        """
        importer = self.assertImportZip(
            'test_import_image.zip',
            ['/root/folder/document',
             '/root/folder/pictures/chocobo',
             '/root/folder/pictures',
             '/root/folder'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(
            self.root.folder.objectIds(),
            ['document', 'pictures'])
        self.assertItemsEqual(
            self.root.folder.pictures.objectIds(),
            ['chocobo'])

        document = self.root.folder.document
        image = self.root.folder.pictures.chocobo
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_viewable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_editable(), None)
        self.assertEqual(version.get_title(), 'New picture shoots')

        service = getUtility(IReferenceService)
        # Hopefully there is only one image in the document so this
        # should match the only link we have
        reference = service.get_reference(version, LINK_REFERENCE_TAG)
        self.assertFalse(reference is None)
        self.assertItemsEqual(
            list(service.get_references_from(version)), [reference])
        self.assertEqual(reference.target, image)

        self.assertDocumentEqual(
            version, 'test_imported_image.docxml',
            image_reference=reference.tags[1])
    def test_document_image(self):
        """Try to import a document that contains an image.
        """
        importer = self.assertImportZip(
            'test_import_image.zip',
            ['/root/folder/document',
             '/root/folder/pictures/chocobo',
             '/root/folder/pictures',
             '/root/folder'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(
            self.root.folder.objectIds(),
            ['document', 'pictures'])
        self.assertItemsEqual(
            self.root.folder.pictures.objectIds(),
            ['chocobo'])

        document = self.root.folder.document
        image = self.root.folder.pictures.chocobo
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_viewable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_editable(), None)
        self.assertEqual(version.get_title(), u'New picture shoots')

        service = getUtility(IReferenceService)
        # Hopefully there is only one image in the document so this
        # should match the only link we have
        reference = service.get_reference(version, LINK_REFERENCE_TAG)
        self.assertFalse(reference is None)
        self.assertItemsEqual(
            list(service.get_references_from(version)), [reference])
        self.assertEqual(reference.target, image)

        self.assertDocumentEqual(
            version, 'test_imported_image.docxml',
            image_reference=reference.tags[1])
예제 #6
0
    def test_document(self):
        """Import a simple document.
        """
        importer = self.assertImportFile(
            'test_import_document.silvaxml',
            ['/root/folder',
             '/root/folder/document'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(self.root.folder.objectIds(), ['document'])

        document = self.root.folder.document
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_editable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_viewable(), None)
        self.assertEqual(version.get_title(), 'Previewing a document')

        binding = self.metadata.getMetadata(version)
        self.assertEqual(
            binding.get('silva-content', 'maintitle'), 'Previewing a document')
        self.assertEqual(
            binding.get('silva-extra', 'content_description'),
            'How to click on preview.')
        self.assertEqual(
            binding.get('silva-extra', 'comment'),
            'Caution: A special skill-set is required for this operation.')
        self.assertDocumentEqual(version, 'test_imported_document.docxml')

        # Test the document have been indexed
        catalog = getUtility(ICatalogService)
        results = catalog(silvamaintitle="previewing document")
        self.assertItemsEqual(
            [r.getPath() for r in results],
            ['/root/folder/document',
             '/root/folder/document/0'])
    def test_document(self):
        """Import a simple document.
        """
        importer = self.assertImportFile(
            'test_import_document.silvaxml',
            ['/root/folder',
             '/root/folder/document'])
        self.assertEqual(importer.getProblems(), [])
        self.assertItemsEqual(self.root.folder.objectIds(), ['document'])

        document = self.root.folder.document
        self.assertTrue(IDocument.providedBy(document))

        version = document.get_editable()
        self.assertFalse(version is None)
        self.assertTrue(IDocumentVersion.providedBy(version))
        self.assertEqual(document.get_viewable(), None)
        self.assertEqual(version.get_title(), u'Previewing a document')

        binding = self.metadata.getMetadata(version)
        self.assertEqual(
            binding.get('silva-content', 'maintitle'), u'Previewing a document')
        self.assertEqual(
            binding.get('silva-extra', 'content_description'),
            u'How to click on preview.')
        self.assertEqual(
            binding.get('silva-extra', 'comment'),
            u'Caution: A special skill-set is required for this operation.')
        self.assertDocumentEqual(version, 'test_imported_document.docxml')

        # Test the document have been indexed
        catalog = getUtility(ICatalogService)
        results = catalog(silvamaintitle=u"previewing document")
        self.assertItemsEqual(
            map(lambda r: r.getPath(), results),
            ['/root/folder/document',
             '/root/folder/document/0'])
 def validate(self, doc):
     return IDocument.providedBy(doc)
 def validate(self, doc):
     return IDocument.providedBy(doc)