Exemple #1
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        self._encoding = self.context.getProperty('default_charset', 'utf-8')

        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None), ) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile(
            '.objects',
            text=stream.getvalue(),
            content_type='text/comma-separated-values',
            subdir=subdir,
        )

        parser = ConfigParser()

        title = self.context.Title()
        description = self.context.Description()
        # encode if needed; ConfigParser does not support unicode !
        title_str = encode_if_needed(title, self._encoding)
        description_str = encode_if_needed(description, self._encoding)
        parser.set('DEFAULT', 'Title', title_str)
        parser.set('DEFAULT', 'Description', description_str)

        stream = StringIO()
        parser.write(stream)

        export_context.writeDataFile(
            '.properties',
            text=stream.getvalue(),
            content_type='text/plain',
            subdir=subdir,
        )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
Exemple #2
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        self._encoding = self.context.getProperty('default_charset', 'utf-8')

        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None),) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile('.objects',
                                     text=stream.getvalue(),
                                     content_type='text/comma-separated-values',
                                     subdir=subdir,
                                    )

        parser = ConfigParser()

        title = self.context.Title()
        description = self.context.Description()
        # encode if needed; ConfigParser does not support unicode !
        title_str = encode_if_needed(title, self._encoding)
        description_str = encode_if_needed(description, self._encoding)
        parser.set('DEFAULT', 'Title', title_str)
        parser.set('DEFAULT', 'Description', description_str)

        stream = StringIO()
        parser.write(stream)

        export_context.writeDataFile('.properties',
                                    text=stream.getvalue(),
                                    content_type='text/plain',
                                    subdir=subdir,
                                    )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
 def testGSContentCompatible(self):
     foo = self.folder[self.folder.invokeFactory('File',
                                                 'foo',
                                                 title='foo',
                                                 file=getData('plone.pdf'))]
     self.assertTrue(IFilesystemExporter(foo))
     self.assertTrue(IFilesystemImporter(foo))
Exemple #4
0
 def listExportableItems(self):
     """ See IFilesystemExporter.
     """
     exportable = self.context.objectItems()
     exportable = [x for x in exportable if not ISetupTool.providedBy(x[1])]
     exportable = [
         x + (IFilesystemExporter(x[1], None), ) for x in exportable
     ]
     return exportable
Exemple #5
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None), ) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile(
            '.objects',
            text=stream.getvalue(),
            content_type='text/comma-separated-values',
            subdir=subdir,
        )

        parser = ConfigParser()

        parser.set('DEFAULT', 'Title', self.context.Title())
        parser.set('DEFAULT', 'Description', self.context.Description())
        stream = StringIO()
        parser.write(stream)

        export_context.writeDataFile(
            '.properties',
            text=stream.getvalue(),
            content_type='text/plain',
            subdir=subdir,
        )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
Exemple #6
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None),) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile('.objects',
                                     text=stream.getvalue(),
                                     content_type='text/comma-separated-values',
                                     subdir=subdir,
                                    )

        parser = ConfigParser()

        parser.set('DEFAULT', 'Title', self.context.Title())
        parser.set('DEFAULT', 'Description', self.context.Description())
        stream = StringIO()
        parser.write(stream)

        export_context.writeDataFile('.properties',
                                    text=stream.getvalue(),
                                    content_type='text/plain',
                                    subdir=subdir,
                                    )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
 def listExportableItems(self):
     ids = self.context.contentIds()
     exportable = self.context.objectItems()
     exportable = [
         (id_, obj) for id_, obj in exportable
         if (id_ in ids or IGenericSetupExportableContainer.providedBy(obj))
     ]
     exportable = [
         x + (IFilesystemExporter(x[1], None), ) for x in exportable
     ]
     exportable = [x for x in exportable if x[2] is not None]
     return exportable
Exemple #8
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None), ) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile(
            '.objects',
            text=stream.getvalue(),
            content_type='text/comma-separated-values',
            subdir=subdir,
        )

        marshaller = self.context.Schema().getLayerImpl('marshall')
        ctype, length, got = marshaller.marshall(self.context)

        export_context.writeDataFile(
            '.properties',
            text=got,
            content_type=ctype,
            subdir=subdir,
        )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None),) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        stream = StringIO()
        csv_writer = writer(stream)

        for object_id, object, ignored in exportable:
            csv_writer.writerow((object_id, object.getPortalTypeName()))

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        export_context.writeDataFile('.objects',
                                     text=stream.getvalue(),
                                     content_type='text/comma-separated-values',
                                     subdir=subdir,
                                    )

        marshaller = self.context.Schema().getLayerImpl('marshall')
        ctype, length, got = marshaller.marshall(self.context)

        export_context.writeDataFile('.properties',
                                    text=got,
                                    content_type=ctype,
                                    subdir=subdir,
                                    )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
Exemple #10
0
    def __call__(self):
        """See ..interfaces.exportimport.IFormFolderExportView.__call__
        """
        ctx = TarballExportContext(self.context)

        self.request.RESPONSE.setHeader('Content-type', 'application/x-gzip')
        self.request.RESPONSE.setHeader(
            'Content-disposition',
            'attachment; filename=%s' % ctx.getArchiveFilename())

        # export the structure treating the current form as our root context
        IFilesystemExporter(self.context).export(ctx, 'structure', True)

        return ctx.getArchive()
    def __call__(self):
        """See ..interfaces.exportimport.IEasyFormExportView.__call__
        """
        ctx = TarballExportContext(self.context)
        response = self.request.RESPONSE
        disposition = 'attachment; filename="{0}-{1:{2}}.tar.gz"'.format(
            self.context.getId(), datetime.now(), '%Y%m%d%H%M%S')

        response.setHeader('Content-type', 'application/x-gzip')
        response.setHeader('Content-disposition', disposition)

        # export the structure treating the current form as our root context
        IFilesystemExporter(self.context).export(ctx, 'structure', True)

        return ctx.getArchive()
def exportPAS(context):
    IFilesystemExporter(context.getSite()).export(context, 'PAS', True)
Exemple #13
0
def exportSiteStructure(context):
    IFilesystemExporter(context.getSite()).export(context, 'structure', True)
Exemple #14
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        content_type = 'text/comma-separated-values'

        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None), ) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        objects_stream = StringIO()
        objects_csv_writer = writer(objects_stream)
        wf_stream = StringIO()
        wf_csv_writer = writer(wf_stream)

        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        try:
            wft = self.context.portal_workflow
        except AttributeError:
            # No workflow tool to export definitions from
            for object_id, object, ignored in exportable:
                objects_csv_writer.writerow(
                    (object_id, object.getPortalTypeName()))
        else:
            for object_id, object, ignored in exportable:
                objects_csv_writer.writerow(
                    (object_id, object.getPortalTypeName()))

                workflows = wft.getWorkflowsFor(object)
                for workflow in workflows:
                    workflow_id = workflow.getId()
                    state_variable = workflow.state_var
                    state_record = wft.getStatusOf(workflow_id, object)
                    if state_record is None:
                        continue
                    state = state_record.get(state_variable)
                    wf_csv_writer.writerow((object_id, workflow_id, state))

            export_context.writeDataFile('.workflow_states',
                                         text=wf_stream.getvalue(),
                                         content_type=content_type,
                                         subdir=subdir)

        export_context.writeDataFile('.objects',
                                     text=objects_stream.getvalue(),
                                     content_type=content_type,
                                     subdir=subdir)

        parser = ConfigParser()

        title = self.context.Title()
        description = self.context.Description()
        # encode if needed; ConfigParser does not support unicode !
        title_str = encode_if_needed(title, self._encoding)
        description_str = encode_if_needed(description, self._encoding)
        parser.set('DEFAULT', 'Title', title_str)
        parser.set('DEFAULT', 'Description', description_str)

        stream = StringIO()
        parser.write(stream)

        try:
            FolderishDAVAwareFileAdapter(self.context).export(
                export_context, subdir, root)
        except (AttributeError, MethodNotAllowed):
            export_context.writeDataFile('.properties',
                                         text=stream.getvalue(),
                                         content_type='text/plain',
                                         subdir=subdir)

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)
 def testGSContentCompatible(self):
     foo = self.folder[self.folder.invokeFactory('Image', 'foo')]
     self.assertTrue(IFilesystemExporter(foo))
     self.assertTrue(IFilesystemImporter(foo))
Exemple #16
0
    def export(self, export_context, subdir, root=False):
        """ See IFilesystemExporter.
        """
        self._encoding = self.context.getProperty('default_charset', 'utf-8')

        # Enumerate exportable children
        exportable = self.context.contentItems()
        exportable = [x + (IFilesystemExporter(x, None),) for x in exportable]
        exportable = [x for x in exportable if x[1] is not None]

        objects_stream = StringIO()
        objects_csv_writer = writer(objects_stream)
        wf_stream = StringIO()
        wf_csv_writer = writer(wf_stream)
        
        
        if not root:
            subdir = '%s/%s' % (subdir, self.context.getId())

        try:
            wft = self.context.portal_workflow
        except AttributeError:
            # No workflow tool to export definitions from
            for object_id, object, ignored in exportable:
                objects_csv_writer.writerow((object_id, object.getPortalTypeName()))
        else:
            for object_id, object, ignored in exportable:
                objects_csv_writer.writerow((object_id, object.getPortalTypeName()))
            
                workflows = wft.getWorkflowsFor(object)
                for workflow in workflows:
                    workflow_id = workflow.getId()
                    state_variable = workflow.state_var
                    state_record = wft.getStatusOf(workflow_id, object)
                    if state_record is None:
                        continue
                    state = state_record.get(state_variable)
                    wf_csv_writer.writerow((object_id, workflow_id, state))
        
            export_context.writeDataFile('.workflow_states',
                                         text=wf_stream.getvalue(),
                                         content_type='text/comma-separated-values',
                                         subdir=subdir,
                                        )
        
        export_context.writeDataFile('.objects',
                                     text=objects_stream.getvalue(),
                                     content_type='text/comma-separated-values',
                                     subdir=subdir,
                                    )

        
        parser = ConfigParser()

        title = self.context.Title()
        description = self.context.Description()
        # encode if needed; ConfigParser does not support unicode !
        title_str = encode_if_needed(title, self._encoding)
        description_str = encode_if_needed(description, self._encoding)
        parser.set('DEFAULT', 'Title', title_str)
        parser.set('DEFAULT', 'Description', description_str)

        stream = StringIO()
        parser.write(stream)

        try:
            FolderishDAVAwareFileAdapter(self.context).export(export_context, subdir, root)
        except (AttributeError, MethodNotAllowed):
            export_context.writeDataFile('.properties',
                                        text=stream.getvalue(),
                                        content_type='text/plain',
                                        subdir=subdir,
                                        )

        for id, object in self.context.objectItems():

            adapter = IFilesystemExporter(object, None)

            if adapter is not None:
                adapter.export(export_context, subdir)