Changeset 5517


Ignore:
Timestamp:
24/07/09 15:16:29 (10 years ago)
Author:
pjkersha
Message:

Added ugly hack to ensure SOAP element name space declaration is present before serialisation as ElementC14N implementation requires this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.common/ndg/security/common/soap.py

    r5516 r5517  
    123123    def _serialize(elem): 
    124124        """Serialise element tree into string""" 
     125         
     126        # Make a basic check for the SOAP name space declaration, if the 
     127        # element is constructed from a call to ElementTree.parse it may not 
     128        # be present  
     129        namespaceDeclarationFound = False 
     130        soapElemNsDeclaration = ( 
     131            'xmlns:%s' % SOAPObject.ELEMENT_PREFIX,  
     132            SOAPObject.DEFAULT_NS 
     133        ) 
     134        if soapElemNsDeclaration[0] not in elem.attrib: 
     135            log.warning("No SOAP namespace declaration found - adding one in") 
     136            elem.set(*soapElemNsDeclaration) 
     137         
    125138        return canonicalize(elem) 
    126139     
     
    255268     
    256269    def prettyPrint(self): 
    257         """Basic pretty printing separating each element on to a new line""" 
     270        """Basic pretty printing separating each element onto a new line""" 
    258271        return ETreeSOAPExtensions._prettyPrint(self.elem) 
    259272     
Note: See TracChangeset for help on using the changeset viewer.