Esempio n. 1
0
def import_mimetypes_registry(registry, xml_filecontent):
    """ Imports the given xml filecontent directly into the mimetypes registry
    """
    portal = registry.portal_url.getPortalObject()
    tool = portal.portal_setup
    imp = DummyImportContext(portal, purge=True, tool=tool)
    doc = parseString(xml_filecontent)
    node = doc.firstChild
    adapter = MimetypesRegistryNodeAdapter(registry, imp)
    adapter._importNode(node)
    return imp.getLogger(adapter._LOGGER_ID)._messages
Esempio n. 2
0
def import_mimetypes_registry(registry, xml_filecontent):
    """ Imports the given xml filecontent directly into the mimetypes registry
    """
    portal = registry.portal_url.getPortalObject()
    tool = portal.portal_setup
    imp = DummyImportContext(portal, purge=True, tool=tool)
    doc = parseString(xml_filecontent)
    node = doc.firstChild
    adapter = MimetypesRegistryNodeAdapter(registry, imp)
    adapter._importNode(node)
    return imp.getLogger(adapter._LOGGER_ID)._messages
Esempio n. 3
0
def export_mimetypes_registry(registry):
    """ Exports the mimetypes registry as xml string
    """
    portal = registry.portal_url.getPortalObject()
    tool = portal.portal_setup
    imp = DummyExportContext(portal, tool=tool)
    adapter = MimetypesRegistryNodeAdapter(registry, imp)
    adapter._doc.appendChild(adapter._exportNode())
    writer = StringIO()
    adapter._doc.writexml(writer, addindent='  ', newl='\n')
    writer.seek(0)
    return writer.read().strip()
Esempio n. 4
0
def export_mimetypes_registry(registry):
    """ Exports the mimetypes registry as xml string
    """
    portal = registry.portal_url.getPortalObject()
    tool = portal.portal_setup
    imp = DummyExportContext(portal, tool=tool)
    adapter = MimetypesRegistryNodeAdapter(registry, imp)
    adapter._doc.appendChild(adapter._exportNode())
    writer = StringIO()
    adapter._doc.writexml(writer, addindent='  ', newl='\n')
    writer.seek(0)
    return writer.read().strip()