def apply(self, store): ops = {"add": self._add} from document import Document document = store.get(self.document_name) if document is None: document = Document.empty(self.document_name) for operation in self.element.iterchildren(): op = ops.get(operation.tag) op(document, operation) return {self.document_name: document}