예제 #1
0
    def test_metadata_to_xml_plone_root(self):

        from xmldirector.plonecore.dx import util

        xml = util.metadata_to_xml(self.portal)
        metadata = util.xml_to_metadata(xml)
        self.assertEqual(metadata['plone-path'], '/plone')
        self.assertEqual(metadata['plone-uid'], None)
    def test_metadata_to_xml_plone_root(self):

        from xmldirector.plonecore.dx import util

        xml = util.metadata_to_xml(self.portal)
        metadata = util.xml_to_metadata(xml)
        self.assertEqual(metadata['plone-path'], '/plone')
        self.assertEqual(metadata['plone-uid'], None)
예제 #3
0
    def get(self):
        """See z3c.form.interfaces.IDataManager"""

        handle = zope.component.getUtility(IWebdavHandle).webdav_handle()
        storage_key = self.storage_key
        if handle.exists(storage_key):
            with handle.open(storage_key, 'rb') as fp:
                with handle.open(storage_key + '.metadata.xml', 'rb') as fp_metadata:
                    xml = fp.read()
                    metadata = util.xml_to_metadata(fp_metadata.read())
            if xml_hash(xml) != metadata['sha256']:
                raise ValueError('Hashes for {} differ'.format(storage_key))
            return xml
예제 #4
0
    def get(self):
        """See z3c.form.interfaces.IDataManager"""

        handle = zope.component.getUtility(IWebdavHandle).webdav_handle()
        storage_key = self.storage_key
        if handle.exists(storage_key):
            with handle.open(storage_key, 'rb') as fp:
                with handle.open(storage_key + '.metadata.xml',
                                 'rb') as fp_metadata:
                    xml = fp.read()
                    metadata = util.xml_to_metadata(fp_metadata.read())
            if xml_hash(xml) != metadata['sha256']:
                raise ValueError('Hashes for {} differ'.format(storage_key))
            return xml
예제 #5
0
    def get(self):
        """See z3c.form.interfaces.IDataManager"""

        handle = zope.component.getUtility(IConnectorHandle).get_handle()
        storage_key = self.storage_key
        if handle.exists(storage_key):
            with handle.open(storage_key, 'rb') as fp:
                with handle.open(storage_key + '.metadata.xml',
                                 'rb') as fp_metadata:
                    data = fp.read()
                    metadata = util.xml_to_metadata(fp_metadata.read())

            if hashlib.sha256(data).hexdigest() != metadata['sha256']:
                raise ValueError(
                    'Invalid hash values for {}'.format(storage_key))

            return self.return_class(data,
                                     filename=metadata['filename'],
                                     contentType=str(metadata['contenttype']))
예제 #6
0
    def get(self):
        """See z3c.form.interfaces.IDataManager"""

        handle = zope.component.getUtility(IWebdavHandle).webdav_handle()
        storage_key = self.storage_key
        if handle.exists(storage_key):
            with handle.open(storage_key, 'rb') as fp:
                with handle.open(storage_key + '.metadata.xml', 'rb') as fp_metadata:
                    data = fp.read()
                    metadata = util.xml_to_metadata(fp_metadata.read())

            if hashlib.sha256(data).hexdigest() != metadata['sha256']:
                raise ValueError(
                    'Invalid hash values for {}'.format(storage_key))

            return self.return_class(
                data,
                filename=metadata['filename'],
                contentType=str(metadata['contenttype']))