Ñò
—ã=Pc           @   sY   d  Z  d d k l Z d d k Td d k l Z e e ƒ Z d	 Z	 d d
 d „  ƒ  YZ
 d S(   s/   
Provides classes for handling soap multirefs.
iÿÿÿÿ(   t	   getLogger(   t   *(   t   Elements)   http://schemas.xmlsoap.org/soap/encoding/t   MultiRefc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sÁ   
    Resolves and replaces multirefs.
    @ivar nodes: A list of non-multiref nodes.
    @type nodes: list
    @ivar catalog: A dictionary of multiref nodes by id.
    @type catalog: dict 
    c         C   s   g  |  _  h  |  _ d  S(   N(   t   nodest   catalog(   t   self(    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyt   __init__&   s    	c         C   s<   g  |  _  h  |  _ |  i | ƒ |  i | ƒ |  i  | _ | S(   s%  
        Process the specified soap envelope body and replace I{multiref} node
        references with the contents of the referenced node.
        @param body: A soap envelope body node.
        @type body: L{Element}
        @return: The processed I{body}
        @rtype: L{Element}
        (   R   R   t   build_catalogt   updatet   children(   R   t   body(    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyt   process*   s    			c         C   s2   |  i  | ƒ x | i D] } |  i | ƒ q W| S(   s-  
        Update the specified I{node} by replacing the I{multiref} references with
        the contents of the referenced nodes and remove the I{href} attribute.
        @param node: A node to update.
        @type node: L{Element}
        @return: The updated node
        @rtype: L{Element}
        (   t   replace_referencesR
   R	   (   R   t   nodet   c(    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyR	   :   s
    	
 c         C   sÊ   | i  d ƒ } | d j o d S| i ƒ  } |  i i | ƒ } | d j o t i d | ƒ d S| i | i ƒ | i	 | i
 ƒ  ƒ x2 | i D]' } | i d j o | i | ƒ qŽ qŽ W| i | ƒ d S(   s  
        Replacing the I{multiref} references with the contents of the 
        referenced nodes and remove the I{href} attribute.  Warning:  since
        the I{ref} is not cloned, 
        @param node: A node to update.
        @type node: L{Element}
        t   hrefNs   soap multiref: %s, not-resolvedt   id(   t   attribt   Nonet   getValueR   t   gett   logt   errort   appendR
   t   setTextt   getTextt
   attributest   namet   remove(   R   R   R   R   t   reft   a(    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyR   H   s    
 c         C   sv   xo | i  D]d } |  i | ƒ o |  i i | ƒ n | i d ƒ } | d j o q
 n d | } | |  i | <q
 Wd S(   sº   
        Create the I{catalog} of multiref nodes by id and the list of
        non-multiref nodes.
        @param body: A soap envelope body node.
        @type body: L{Element}
        R   s   #%sN(   R
   t   soaprootR   R   R   R   R   (   R   R   t   childR   t   key(    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyR   _   s    
  
c         C   s8   | i  d d t ƒ} | d j o t S| i d j Sd S(   sj  
        Get whether the specified I{node} is a soap encoded root.
        This is determined by examining @soapenc:root='1'.
        The node is considered to be a root when the attribute
        is not specified.
        @param node: A node to evaluate.
        @type node: L{Element}
        @return: True if a soap encoded root.
        @rtype: bool
        t   roott   nst   1N(   R   t   soapencR   t   Truet   value(   R   R   R#   (    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyR    n   s    (	   t   __name__t
   __module__t   __doc__R   R   R	   R   R   R    (    (    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyR      s   					N(   Ns)   http://schemas.xmlsoap.org/soap/encoding/(    (   R+   t   loggingR    t   sudst   suds.sax.elementR   R)   R   R   R&   R   (    (    (    sU   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/bindings/multiref.pyt   <module>   s   
