³ò
—ã=Pc           @   sA  d  Z  d d k l Z d d k Td d k l Z d d k l Z d d k l	 Z	 d d k
 l Z l Z d d k l Z d d	 k l Z d d
 k l Z d d k l Z d d k l Z d d k l Z l Z d d k l	 Z d d k l  Z  d d k! l" Z" e e# ƒ Z$ d d f Z% d f  d „  ƒ  YZ& d e f d „  ƒ  YZ' d S(   s*   
Provides classes for (WS) SOAP bindings.
iÿÿÿÿ(   t	   getLogger(   t   *(   t	   Namespace(   t   Parser(   t   Element(   t   Factoryt   Object(   t   Content(   t   Literal(   t   Basic(   t   Typed(   t   MultiRef(   t	   TypeQueryt   ElementQuery(   t   Options(   t   deepcopys   SOAP-ENVs)   http://schemas.xmlsoap.org/soap/envelope/t   Bindingc           B   sÔ   e  Z d  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z e d „ Z d „  Z RS(   s  
    The soap binding class used to process outgoing and imcoming
    soap messages per the WSDL port binding.
    @cvar replyfilter: The reply filter function.
    @type replyfilter: (lambda s,r: r)
    @ivar wsdl: The wsdl.
    @type wsdl: L{suds.wsdl.Definitions}
    @ivar schema: The collective schema contained within the wsdl.
    @type schema: L{xsd.schema.Schema}
    @ivar options: A dictionary options.
    @type options: L{Options}
    @ivar parser: A sax parser.
    @type parser: L{suds.sax.parser.Parser}
    c         C   s   | S(    (    (   t   st   r(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   <lambda>:   s    c         C   s=   | |  _  | i |  _ t ƒ  |  _ t ƒ  |  _ t ƒ  |  _ d S(   sN   
        @param wsdl: A wsdl.
        @type wsdl: L{wsdl.Definitions}
        N(   t   wsdlt   schemaR   t   optionsR   t   parserR   t   multiref(   t   selfR   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   __init__<   s
    	c         C   s#   | o t  |  i ƒ Sn t ƒ  Sd S(   s†   
        Get the appropriate XML decoder.
        @return: Either the (basic|typed) unmarshaller.
        @rtype: L{UmxTyped}
        N(   t   UmxTypedR   t   UmxBasic(   R   t   typed(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   unmarshallerG   s    c         C   s   t  |  i ƒ S(   s|   
        Get the appropriate XML encoder.
        @return: An L{MxLiteral} marshaller.
        @rtype: L{MxLiteral}
        (   t	   MxLiteralR   (   R   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt
   marshallerR   s    c         C   s   t  d ‚ d S(   s  
        Get parameter definitions.  
        Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
        @param method: A servic emethod.
        @type method: I{service.Method}
        @return: A collection of parameter definitions
        @rtype: [I{pdef},..]
        s   not implementedN(   t	   Exception(   R   t   method(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt
   param_defsZ   s    	c         C   s‡   |  i  | ƒ } |  i | ƒ } |  i | | | ƒ } |  i | ƒ } |  i | | ƒ } |  i i o | i ƒ  | i ƒ  n | i	 ƒ  | S(   sâ  
        Get the soap message for the specified method, args and soapheaders.
        This is the entry point for creating the outbound soap message.
        @param method: The method being invoked.
        @type method: I{service.Method}
        @param args: A list of args for the method invoked.
        @type args: list
        @param kwargs: Named (keyword) args for the method invoked.
        @type kwargs: dict
        @return: The soap message.
        @rtype: str
        (
   t   headercontentt   headert   bodycontentt   bodyt   envelopeR   t   prefixest   normalizePrefixest   promotePrefixest   refitPrefixes(   R   R"   t   argst   kwargst   contentR%   R'   t   env(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   get_messagee   s    

c         C   s[  |  i  | ƒ } |  i i d | ƒ } | i d ƒ } | i ƒ  | i d ƒ } |  i i | ƒ } |  i | | ƒ } |  i | ƒ } t	 | ƒ d j o  |  i
 | | ƒ } | | f Sn t	 | ƒ d j oŒ | d i ƒ  o$ |  i | d | ƒ } | | f Sn t	 | ƒ oF |  i ƒ  }	 | d i d t ƒ }
 |	 i | d |
 ƒ } | | f SqQn | d f S(   s>  
        Process the I{reply} for the specified I{method} by sax parsing the I{reply}
        and then unmarshalling into python object(s).
        @param method: The name of the invoked method.
        @type method: str
        @param reply: The reply XML received after invoking the specified method.
        @type reply: str
        @return: The unmarshalled reply.  The returned value is an L{Object} for a
            I{list} depending on whether the service returns a single object or a 
            collection.
        @rtype: tuple ( L{Element}, L{Object} )
        t   stringt   Envelopet   Bodyi   i    t	   nobuiltinN(   t   replyfilterR   t   parset   getChildR+   R   t   processt   replycontentt   returned_typest   lent   replycompositet	   unboundedt	   replylistR   t   resolvet   Truet   None(   R   R"   t   replyt	   replyroott   soapenvt   soapbodyt   nodest   rtypest   resultR   t   resolved(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt	   get_reply   s*    
c         C   sX   g  } | i  d t ƒ } |  i ƒ  } x- | D]% } | i | | ƒ } | i | ƒ q+ W| S(   s‚  
        Construct a I{list} reply.  This mehod is called when it has been detected
        that the reply is a list.
        @param rt: The return I{type}.
        @type rt: L{suds.xsd.sxbase.SchemaObject}
        @param nodes: A collection of XML nodes.
        @type nodes: [L{Element},...]
        @return: A list of I{unmarshalled} objects.
        @rtype: [L{Object},...]
        R5   (   R@   RA   R   R9   t   append(   R   t   rtRG   RI   RJ   R   t   nodet   sobject(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR?   ¢   s     c         C   s8  h  } x | D] } | | | i  <q W|  i ƒ  } t i d ƒ } xò | D]ê } | i  } | i | d ƒ } | d j o1 | i d ƒ d j o t d | ƒ ‚ q¥ qF n | i d t ƒ }	 | i	 | |	 ƒ }
 | i
 ƒ  oJ t | | d ƒ } | d j o g  } t | | | ƒ n | i |
 ƒ qF t | | |
 ƒ qF W| S(   s²  
        Construct a I{composite} reply.  This method is called when it has been
        detected that the reply has multiple root nodes.
        @param rtypes: A list of known return I{types}.
        @type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
        @param nodes: A collection of XML nodes.
        @type nodes: [L{Element},...]
        @return: The I{unmarshalled} composite object.
        @rtype: L{Object},...
        RC   t   ids    <%s/> not mapped to message partR5   N(   t   nameR   R   t   objectt   getRB   R!   R@   RA   R9   R>   t   getattrt   setattrRL   (   R   RH   RG   t
   dictionaryRM   R   t	   compositeRN   t   tagRJ   RO   t   value(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR=   µ   s0      	c         C   sœ   |  i  | ƒ } |  i i d | ƒ } | i d ƒ } | i d ƒ } | i d ƒ } |  i t ƒ } | i | ƒ } |  i i o t	 | | ƒ ‚ n | | i
 f S(   s’  
        Extract the fault from the specified soap reply.  If I{faults} is True, an
        exception is raised.  Otherwise, the I{unmarshalled} fault L{Object} is
        returned.  This method is called when the server raises a I{web fault}.
        @param reply: A soap reply message.
        @type reply: str
        @return: A fault object.
        @rtype: tuple ( L{Element}, L{Object} )
        R2   R3   R4   t   Fault(   R6   R   R7   R8   R   t   FalseR9   R   t   faultst   WebFaultt   detail(   R   RC   t	   faultrootRE   RF   t   faultR   t   p(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt	   get_faultÙ   s    
c      
   C   s   |  i  ƒ  } t | t t f ƒ o; g  } x* | D]" } | i |  i | | | ƒ ƒ q/ W| Sn t d | d d | d | d ƒ } | i | ƒ S(   sÈ  
        Builds a parameter for the specified I{method} using the parameter
        definition (pdef) and the specified value (object).
        @param method: A method name.
        @type method: str
        @param pdef: A parameter definition.
        @type pdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
        @param object: The parameter value.
        @type object: any
        @return: The parameter fragment.
        @rtype: L{Element}
        RX   i    RY   t   typei   (   R    t
   isinstancet   listt   tupleRL   t   mkparamR   R9   (   R   R"   t   pdefRR   R    t   tagst   itemR/   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyRg   î   s      #c      
   C   s   |  i  ƒ  } t | t t f ƒ o; g  } x* | D]" } | i |  i | | | ƒ ƒ q/ W| Sn t d | d d | d | d ƒ } | i | ƒ S(   sÀ  
        Builds a soapheader for the specified I{method} using the header
        definition (hdef) and the specified value (object).
        @param method: A method name.
        @type method: str
        @param hdef: A header definition.
        @type hdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
        @param object: The header value.
        @type object: any
        @return: The parameter fragment.
        @rtype: L{Element}
        RX   i    RY   Rc   i   (   R    Rd   Re   Rf   RL   t   mkheaderR   R9   (   R   R"   t   hdefRR   R    Ri   Rj   R/   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyRk     s      #c         C   sN   t  d d t ƒ} | i t i d t i d ƒ | i | ƒ | i | ƒ | S(   sH  
        Build the B{<Envelope/>} for an soap outbound message.
        @param header: The soap message B{header}.
        @type header: L{Element}
        @param body: The soap message B{body}.
        @type body: L{Element}
        @return: The soap envelope containing the body and header.
        @rtype: L{Element}
        R3   t   nsi    i   (   R   t   envnst	   addPrefixR   t   xsinsRL   (   R   R%   R'   R0   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR(     s
    
c         C   s#   t  d d t ƒ} | i | ƒ | S(   sÖ   
        Build the B{<Body/>} for an soap outbound message.
        @param content: The header content.
        @type content: L{Element}
        @return: the soap body fragment.
        @rtype: L{Element}
        t   HeaderRm   (   R   Rn   RL   (   R   R/   R%   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR%   *  s    c         C   s   t  d ‚ d S(   sƒ  
        Get the content for the soap I{body} node.
        @param method: A service method.
        @type method: I{service.Method}
        @param args: method parameter values
        @type args: list
        @param kwargs: Named (keyword) args for the method invoked.
        @type kwargs: dict
        @return: The xml content for the <body/>
        @rtype: [L{Element},..]
        s   not implementedN(   R!   (   R   R"   R-   R.   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR&   6  s    c         C   sí  d } g  } |  i  i } | d j	 o | i | i ƒ  ƒ n |  i  i } t | t t t	 f ƒ p | f } n t
 | ƒ d j o | Sn |  i | ƒ } t | t t f ƒ o¶ x8| D]§ } t | t ƒ o | i t | ƒ ƒ qµ n t
 | ƒ | j o Pn |  i | | | | ƒ } | | d i d ƒ }	 | i |	 d |	 d ƒ | i | ƒ | d 7} qµ Wn† x‚ | D]z }
 | i |
 d ƒ } | d j o qkn |  i | |
 | ƒ } |
 d i d ƒ }	 | i |	 d |	 d ƒ | i | ƒ qkW| S(   sà   
        Get the content for the soap I{Header} node.
        @param method: A service method.
        @type method: I{service.Method}
        @return: The xml content for the <body/>
        @rtype: [L{Element},..]
        i    i   t   ns0N(   R   t   wsseRB   RL   t   xmlt   soapheadersRd   Rf   Re   t   dictR<   t   headpart_typesR   R   Rk   t	   namespacet	   setPrefixRS   (   R   R"   t   nR/   Rs   t   headerst   ptsR%   t   hRm   t   pt(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR$   D  sD       c         C   s   t  d ‚ d S(   s  
        Get the reply body content.
        @param method: A service method.
        @type method: I{service.Method}
        @param body: The soap body
        @type body: L{Element}
        @return: the body content
        @rtype: [L{Element},...]
        s   not implementedN(   R!   (   R   R"   R'   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR:   m  s    
c         C   s#   t  d d t ƒ} | i | ƒ | S(   sÔ   
        Build the B{<Body/>} for an soap outbound message.
        @param content: The body content.
        @type content: L{Element}
        @return: the soap body fragment.
        @rtype: L{Element}
        R4   Rm   (   R   Rn   RL   (   R   R/   R'   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR'   y  s    c         C   s,  g  } | o | i  i i i } n | i  i i i } xð | D]è } | i d j	 o t | i ƒ } n t | i	 ƒ } | i
 |  i ƒ } | d j o t | i ƒ ‚ n | i	 d j	 o t | i | ƒ } n | oD | i d j o | i | i | f ƒ q$| i | i | f ƒ q< | i | ƒ q< W| S(   s–  
        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},]
        N(   t   soapt   inputR'   t   partst   outputt   elementRB   R   R   Rc   t   executeR   t   TypeNotFoundt   reft   PartElementRQ   RL   (   R   R"   R€   RI   R   Ra   t   queryR~   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   bodypart_types…  s(     c   	      C   s/  g  } | o | i  i i } n | i  i i } xù | D]ñ } | i } | i d j	 o t | i ƒ } n t | i	 ƒ } | i
 |  i ƒ } | d j o t | i ƒ ‚ n | i	 d j	 o t | i | ƒ } n | oD | i d j o | i | i | f ƒ q'| i | i | f ƒ q6 | i | ƒ q6 W| S(   s–  
        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},]
        N(   R   R€   R{   R‚   t   partRƒ   RB   R   R   Rc   R„   R   R…   R†   R‡   RQ   RL   (	   R   R"   R€   RI   R{   R%   RŠ   Rˆ   R~   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyRw   ¨  s*     	c         C   s7   g  } x* |  i  | d t ƒD] } | i | ƒ q W| S(   sú   
        Get the L{xsd.sxbase.SchemaObject} returned by the I{method}.
        @param method: A service method.
        @type method: I{service.Method}
        @return: The name of the type return by the method.
        @rtype: [I{rtype},..]
        R€   (   R‰   R[   RL   (   R   R"   RI   RM   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR;   Ì  s
     (   t   __name__t
   __module__t   __doc__R6   R   RA   R   R    R#   R1   RK   R?   R=   Rb   Rg   Rk   R(   R%   R&   R$   R:   R'   R‰   Rw   R;   (    (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR   *   s,   						#		$							)		#$R‡   c           B   s8   e  Z d  Z d „  Z d „  Z d d „ Z e d „ Z RS(   sÖ   
    A part used to represent a message part when the part
    references a schema type and thus assumes to be an element.
    @ivar resolved: The part type.
    @type resolved: L{suds.xsd.sxbase.SchemaObject}
    c         C   sJ   t  d d t i ƒ} t i |  | i | ƒ | |  _ | |  _ t |  _	 d S(   s¥   
        @param name: The part name.
        @type name: str
        @param resolved: The part type.
        @type resolved: L{suds.xsd.sxbase.SchemaObject}
        Rƒ   Rm   N(
   R   R   t   xsdnst   SchemaElementR   R   t   _PartElement__resolvedRQ   R[   t   form_qualified(   R   RQ   RJ   t   root(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR   â  s
    		c         C   s   |  S(   N(    (   R   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyt   implanyï  s    c         C   s   t  i S(   N(   R   t   default(   R   t   prefix(    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyRx   ò  s    c         C   s*   | o |  i  i ƒ  o |  Sn |  i  Sd  S(   N(   R   t   builtin(   R   R5   (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR@   õ  s    N(	   R‹   RŒ   R   R   R“   RB   Rx   R[   R@   (    (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pyR‡   Ú  s
   		N((   R   t   loggingR    t   sudst   suds.saxR   t   suds.sax.parserR   t   suds.sax.elementR   t   suds.sudsobjectR   R   t   suds.mxR   t   suds.mx.literalR   R   t   suds.umx.basicR	   R   t   suds.umx.typedR
   R   t   suds.bindings.multirefR   t   suds.xsd.queryR   R   t   suds.xsd.sxbasicR   t   suds.optionsR   t   copyR   R‹   t   logRn   R   R‡   (    (    (    s-   suds-0.3.7-py2.6.egg/suds/bindings/binding.pys   <module>   s(   
ÿ ±