Example #1
0
    def create_in_document(self, ctx, charset=None):
        super(BaseSmev, self).create_in_document(ctx, charset)
        in_document, _ = ctx.in_document
        if ctx.udc is None:
            ctx.udc = _utils.EmptyCtx()
        ctx.udc.in_smev_header_document = in_document.find(
            ".//{{{smev}}}Header".format(**self._ns))
        ctx.udc.in_smev_message_document = in_document.find(
            ".//{{{smev}}}Message".format(**self._ns))
        ctx.udc.in_smev_appdoc_document = in_document.find(
            ".//{{{smev}}}AppDocument".format(**self._ns))
        message_data = in_document.find(
            ".//{{{smev}}}MessageData".format(**self._ns))

        if any(map(_utils.isnone,
                   (ctx.udc.in_smev_message_document, message_data))):
            raise _Fault("SMEV-100010", "Invalid configuration!")

        map(self._validate_smev_element, filter(_utils.notisnone, (
            ctx.udc.in_smev_message_document,
            ctx.udc.in_smev_header_document,
            message_data)))
        method_data = message_data.find(
            ".//{{{smev}}}AppData".format(**self._ns)).getchildren()
        method = in_document.find(
            ".//{{{0}}}Body".format(_ns.soapenv)).getchildren()[0]
        method.clear()
        method.extend(method_data)
        self.event_manager.fire_event('smev_in_document_built', ctx)
Example #2
0
 def _validate_smev_element(self, element):
     self._smev_schema = self._smev_schema or _utils.load_schema(
         self._smev_schema_path)
     if not self._smev_schema.validate(element):
         errors = "\n".join((
             err.message for err in self._smev_schema.error_log))
         raise _Fault(
             "SMEV-102000",
             "Message didn't pass validation checks!"
             " Errors:\n{0}".format(errors))