Changeset 4050 for waeup


Ignore:
Timestamp:
2 Apr 2009, 11:39:41 (16 years ago)
Author:
uli
Message:

First simple implementation of a gerneral purpose importer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/utils/importexport.py

    r4047 r4050  
    77from xml.dom.minidom import Document, getDOMImplementation
    88from zope.interface import Interface
    9 from waeup.interfaces import IWAeUPObject, IWAeUPExporter, IWAeUPXMLExporter
     9from waeup.interfaces import (IWAeUPObject, IWAeUPExporter, IWAeUPXMLExporter,
     10                              IWAeUPXMLImporter)
    1011
    1112def readFile(f):
     
    6768        return filelike_obj
    6869
     70class XMLImporter(grok.Adapter):
     71    """Import a WAeUP object from XML.
     72    """
     73    grok.context(Interface)
     74    grok.provides(IWAeUPXMLImporter)
     75
     76    def __init__(self, context):
     77        self.context = context
     78   
     79    def doImport(self, filepath):
     80        xml = open(filepath, 'rb').read()
     81        obj = zope.xmlpickle.loads(xml)
     82        return obj
     83
Note: See TracChangeset for help on using the changeset viewer.