コード例 #1
0
ファイル: sxbasic.py プロジェクト: uhla/suds-sw
 def resolve(self, nobuiltin=False):
     qref = self.qref()
     if qref is None:
         return self
     key = 'resolved:nb=%s' % nobuiltin
     cached = self.cache.get(key)
     if cached is not None:
         return cached
     result = self
     query = TypeQuery(qref)
     query.history = [self]
     log.debug('%s, resolving: %s\n using:%s', self.id, qref, query)
     resolved = query.execute(self.schema)
     if resolved is None:
         log.debug(self.schema)
         raise TypeNotFound(qref)
     self.cache[key] = resolved
     if resolved.builtin():
         if nobuiltin:
             result = self
         else:
             result = resolved
     else:
         result = resolved.resolve(nobuiltin)
     return result
コード例 #2
0
ファイル: binding.py プロジェクト: EASYMARKETING/suds-jurko
    def __part_type(self, part, input):
        """
        Get a I{parameter definition} (pdef) defined for a given body or header
        message part.

        An input I{pdef} is a (I{name}, L{xsd.sxbase.SchemaObject}) tuple,
        while an output I{pdef} is a L{xsd.sxbase.SchemaObject}.

        @param part: A service method input or output part.
        @type part: I{suds.wsdl.Part}
        @param input: Defines input/output message.
        @type input: boolean
        @return:  A list of parameter definitions
        @rtype: [I{pdef},...]

        """
        if part.element is None:
            query = TypeQuery(part.type)
        else:
            query = ElementQuery(part.element)
        part_type = query.execute(self.schema())
        if part_type is None:
            raise TypeNotFound(query.ref)
        if part.type is not None:
            part_type = PartElement(part.name, part_type)
        if not input:
            return part_type
        if part_type.name is None:
            return part.name, part_type
        return part_type.name, part_type
コード例 #3
0
ファイル: binding.py プロジェクト: ziaa/suds-jurko
    def __part_type(self, part, input):
        """
        Get a I{parameter definition} (pdef) defined for a given body or header
        message part.

        An input I{pdef} is a (I{name}, L{xsd.sxbase.SchemaObject}) tuple,
        while an output I{pdef} is a L{xsd.sxbase.SchemaObject}.

        @param part: A service method input or output part.
        @type part: I{suds.wsdl.Part}
        @param input: Defines input/output message.
        @type input: boolean
        @return:  A list of parameter definitions
        @rtype: [I{pdef},...]

        """
        if part.element is None:
            query = TypeQuery(part.type)
        else:
            query = ElementQuery(part.element)
        part_type = query.execute(self.schema())
        if part_type is None:
            raise TypeNotFound(query.ref)
        if part.type is not None:
            part_type = PartElement(part.name, part_type)
        if not input:
            return part_type
        if part_type.name is None:
            return part.name, part_type
        return part_type.name, part_type
コード例 #4
0
ファイル: sxbasic.py プロジェクト: chatoooo/suds-ng
 def resolve(self, nobuiltin=False):
     qref = self.qref()
     if qref is None:
         return self
     key = 'resolved:nb=%s' % nobuiltin
     cached = self.cache.get(key)
     if cached is not None:
         return cached
     result = self
     query = TypeQuery(qref)
     query.history = [self]
     log.debug('%s, resolving: %s\n using:%s', self.id, qref, query)
     resolved = query.execute(self.schema)
     if resolved is None:
         log.debug(self.schema)
         raise TypeNotFound(qref)
     self.cache[key] = resolved
     if resolved.builtin():
         if nobuiltin:
             result = self
         else:
             result = resolved
     else:
         result = resolved.resolve(nobuiltin)
     return result
コード例 #5
0
ファイル: sxbasic.py プロジェクト: uhla/suds-sw
 def dependencies(self):
     deps = []
     midx = None
     if self.ref is not None:
         query = TypeQuery(self.ref)
         super = query.execute(self.schema)
         if super is None:
             log.debug(self.schema)
             raise TypeNotFound(self.ref)
         if not super.builtin():
             deps.append(super)
             midx = 0
     return (midx, deps)
コード例 #6
0
ファイル: sxbasic.py プロジェクト: chatoooo/suds-ng
 def dependencies(self):
     deps = []
     midx = None
     if self.ref is not None:
         query = TypeQuery(self.ref)
         super = query.execute(self.schema)
         if super is None:
             log.debug(self.schema)
             raise TypeNotFound(self.ref)
         if not super.builtin():
             deps.append(super)
             midx = 0
     return (midx, deps)
コード例 #7
0
ファイル: binding.py プロジェクト: EnetModa/suds-philpem
 def headpart_types(self, method, input=True):
     """
     Get a list of I{parameter definitions} (pdef) defined for the specified method.
     Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
     @param method: A service method.
     @type method: I{service.Method}
     @param input: Defines input/output message.
     @type input: boolean
     @return:  A list of parameter definitions
     @rtype: [I{pdef},]
     """
     result = []
     if input:
         headers = method.soap.input.headers
     else:
         headers = method.soap.output.headers
     for header in headers:
         part = header.part
         if part.element is not None:
             query = ElementQuery(part.element)
         else:
             query = TypeQuery(part.type)
         pt = query.execute(self.schema())
         if pt is None:
             raise TypeNotFound(query.ref)
         if part.type is not None:
             pt = PartElement(part.name, pt)
         if input:
             if pt.name is None:
                 result.append((part.name, pt))
             else:
                 result.append((pt.name, pt))
         else:
             result.append(pt)
     return result
コード例 #8
0
 def bodypart_types(method, schema, input=True):
     """
     This returns the types of a soap body.
     This is basically copied from the suds source code (suds.bindings.binding)
     """
     result = []
     if input:
         parts = method.soap.input.body.parts
     else:
         parts = method.soap.output.body.parts
     for p in parts:
         if p.element is not None:
             query = ElementQuery(p.element)
         else:
             query = TypeQuery(p.type)
         pt = query.execute(schema)
         if pt is None:
             raise TypeNotFound(query.ref)
         if p.type is not None:
             pt = TypeNotFound(p.name, pt)
         if input:
             if pt.name is None:
                 result.append((p.name, pt))
             else:
                 result.append((pt.name, pt))
         else:
             result.append(pt)
     return result
コード例 #9
0
    def marshal_exception(self, exc, method):

        raise NotImplementedError("cannot yet handle exceptions")

        # The following code is very much unfinished and there is no
        # guaranty that it is correct or even makes sense
        # Currently it finds the fault return types (there should only
        # be one AFAICT). How to get from there and to to a fault body
        # is still open.

        from suds import TypeNotFound
        from suds.bindings.binding import PartElement
        from suds.xsd.query import TypeQuery, ElementQuery

        rtypes = []

        for f in method.unwrapped_.soap.faults:
            for p in f.parts:
                if p.element is not None:
                    query = ElementQuery(p.element)
                else:
                    query = TypeQuery(p.type)
                pt = query.execute(method.binding.output.schema())
                if pt is None:
                    raise TypeNotFound(query.ref)
                if p.type is not None:
                    pt = PartElement(p.name, pt)
                rtypes.append(pt)

        return rtypes
コード例 #10
0
ファイル: encoded.py プロジェクト: BhallaLab/moose-gui
 def cast(self, content):
     """
     Cast the I{untyped} list items found in content I{value}.
     Each items contained in the list is checked for XSD type information.
     Items (values) that are I{untyped}, are replaced with suds objects and
     type I{metadata} is added.
     @param content: The content holding the collection.
     @type content: L{Content}
     @return: self
     @rtype: L{Encoded}
     """
     aty = content.aty[1]
     resolved = content.type.resolve()
     array = Factory.object(resolved.name)
     array.item = []
     query = TypeQuery(aty)
     ref = query.execute(self.schema)
     if ref is None:
         raise TypeNotFound(qref)
     for x in content.value:
         if isinstance(x, (list, tuple)):
             array.item.append(x)
             continue
         if isinstance(x, Object):
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         if isinstance(x, dict):
             x = Factory.object(ref.name, x)
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         x = Factory.property(ref.name, x)
         md = x.__metadata__
         md.sxtype = ref
         array.item.append(x)
     content.value = array
     return self
コード例 #11
0
ファイル: encoded.py プロジェクト: BhallaLab/moose-package
 def cast(self, content):
     """
     Cast the I{untyped} list items found in content I{value}.
     Each items contained in the list is checked for XSD type information.
     Items (values) that are I{untyped}, are replaced with suds objects and
     type I{metadata} is added.
     @param content: The content holding the collection.
     @type content: L{Content}
     @return: self
     @rtype: L{Encoded}
     """
     aty = content.aty[1]
     resolved = content.type.resolve()
     array = Factory.object(resolved.name)
     array.item = []
     query = TypeQuery(aty)
     ref = query.execute(self.schema)
     if ref is None:
         raise TypeNotFound(qref)
     for x in content.value:
         if isinstance(x, (list, tuple)):
             array.item.append(x)
             continue
         if isinstance(x, Object):
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         if isinstance(x, dict):
             x = Factory.object(ref.name, x)
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         x = Factory.property(ref.name, x)
         md = x.__metadata__
         md.sxtype = ref
         array.item.append(x)
     content.value = array
     return self