def parse(self,
              element,
              original=None,
              table=None,
              tree=None,
              files=None):

        s3db = current.s3db
        xml = current.xml

        ERROR = xml.ATTRIBUTE["error"]

        self.element = element
        if table is None:
            tablename = element.get(xml.ATTRIBUTE["name"], None)
            table = s3db.table(tablename)
            if table is None:
                self.error = current.ERROR.BAD_RESOURCE
                element.set(ERROR, s3_unicode(self.error))
                return False

        self.table = table
        self.tablename = table._tablename

        UID = xml.UID

        if original is None:
            original = S3Resource.original(table, element,
                                           mandatory = self._mandatory_fields())
        elif isinstance(original, basestring) and UID in table.fields:
            # Single-component update in add-item => load the original now
            query = (table[UID] == original)
            pkeys = set(fname for fname in table.fields if table[fname].unique)
            fields = S3Resource.import_fields(table, pkeys,
                                              mandatory = self._mandatory_fields())
            original = current.db(query).select(limitby=(0, 1), *fields).first()
        else:
            original = None

        postprocess = s3db.get_config(self.tablename, "xml_post_parse")
        data = xml.record(table, element,
                          files=files,
                          original=original,
                          postprocess=postprocess)

        if data is None:
            self.error = current.ERROR.VALIDATION_ERROR
            self.accepted = False
            if not element.get(ERROR, False):
                element.set(ERROR, s3_unicode(self.error))
            return False

        self.data = data

        MCI = xml.MCI
        MTIME = xml.MTIME

        self.uid = data.get(UID)
        if original is not None:

            self.original = original
            self.id = original[table._id.name]

            if not current.response.s3.synchronise_uuids and UID in original:
                self.uid = self.data[UID] = original[UID]

        if MTIME in data:
            self.mtime = data[MTIME]
        if MCI in data:
            self.mci = data[MCI]

        _debug("New item: %s", self)
        return True

    # -------------------------------------------------------------------------
Read data from a <resource> element
dataset/ETHPy150Open sahana/eden/modules/s3/s3import.py/S3ImportItem.parse