Utility
index
/home/groups/p/py/pywebsvcs/src/wstools/Utility.py

# Copyright (c) 2003, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of
# any required approvals from the U.S. Dept. of Energy).  All rights
# reserved. 
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.

 
Modules
       
httplib
logging
socket
sys
types
urllib
weakref
xml

 
Classes
       
Base
ElementProxy(Base, MessageInterface)
exceptions.Exception
DOMException
NamespaceError
ParseError
RecursionError
httplib.HTTPConnection
TimeoutHTTP
HTTPResponse
httplib.HTTPSConnection(httplib.HTTPConnection)
TimeoutHTTPS
MessageInterface
UserDict.UserDict
Collection
CollectionNS

 
class Base
    Base class for instance level Logging
 
  Methods defined here:
__init__(self, module='Utility')

 
class Collection(UserDict.UserDict)
    Helper class for maintaining ordered named collections.
 
  Methods defined here:
__getitem__(self, key)
__init__(self, parent, key=None)
__setitem__(self, key, item)
default lambda self, k
items(self)
keys(self)
values(self)

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

 
class CollectionNS(UserDict.UserDict)
    Helper class for maintaining ordered named collections.
 
  Methods defined here:
__getitem__(self, key)
__init__(self, parent, key=None)
__setitem__(self, key, item)
default lambda self, k
items(self)
keys(self)
values(self)

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

 
class DOMException(exceptions.Exception)
    Used to indicate a problem processing DOM.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ElementProxy(Base, MessageInterface)
    
Method resolution order:
ElementProxy
Base
MessageInterface

Methods defined here:
__init__(self, sw, message=None)
Initialize. 
sw -- SoapWriter
__str__(self)
canonicalize(self)
checkNode(self, namespaceURI=None, localName=None)
namespaceURI -- namespace of element
localName -- local name of element
createAppendElement(self, namespaceURI, localName, prefix=None)
Create a new element (namespaceURI,name), append it
   to current node, and return the newly created node.
Keyword arguments:
    namespaceURI -- namespace of element to create
    localName -- local name of new element
    prefix -- if namespaceURI is not defined, declare prefix.  defaults
        to 'ns1' if left unspecified.
createAppendSetElement(self, namespaceURI, localName, prefix=None)
Create a new element (namespaceURI,name), append it
   to current node, then set it to be the current node.
Keyword arguments:
    namespaceURI -- namespace of element to create
    localName -- local name of new element
    prefix -- if namespaceURI is not defined, declare prefix.  defaults
        to 'ns1' if left unspecified.
createAppendTextNode(self, pyobj)
#############################################
#Methods for text nodes
#############################################
createAttributeNS(self, namespace, name, value)
createDocument(self, namespaceURI, localName, doctype=None)
If specified must be a SOAP envelope, else may contruct an empty document.
createElementNS(self, namespace, qname)
Keyword arguments:
    namespace -- namespace of element to create
    qname -- qualified name of new element
createInsertBefore(self, namespaceURI, localName, refChild)
createTextNode(self, pyobj)
evaluate(self, expression, processorNss=None)
expression -- XPath compiled expression
findNamespaceURI(self, qualifiedName)
#############################################
#Methods for retrieving namespaceURI's
#############################################
getAttributeValue(self, namespaceURI, localName)
Keyword arguments:
    namespaceURI -- namespace of attribute
    localName -- local name of attribute
getDocument(self)
getElement(self, namespaceURI, localName)
Keyword arguments:
    namespaceURI -- namespace of element
    localName -- local name of element
getPrefix(self, namespaceURI)
getSOAPEnvURI(self)
getValue(self)
hasAttribute(self, namespaceURI, localName)
#############################################
#Methods for attributes
#############################################
importFromString(self, xmlString)
importNode(self, node)
isEmpty(self)
isFault(self)
check to see if this is a soap:fault message.
loadFromString(self, data)
resolvePrefix(self, prefix)
setAttributeNS(self, namespaceURI, localName, value)
Keyword arguments:
    namespaceURI -- namespace of attribute to create, None is for
        attributes in no namespace.
    localName -- local name of new attribute
    value -- value of new attribute
setAttributeType(self, namespaceURI, localName)
set xsi:type
Keyword arguments:
    namespaceURI -- namespace of attribute value
    localName -- name of new attribute value
setDocument(self, document)
setNamespaceAttribute(self, prefix, namespaceURI)
Keyword arguments:
    prefix -- xmlns prefix
    namespaceURI -- value of prefix
setNode(self, node=None)
toString(self)

Data and other attributes defined here:
name = None
namespaceURI = None
reserved_ns = {'SOAP-ENC': 'http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENV': 'http://schemas.xmlsoap.org/soap/envelope/', 'ZSI': 'http://www.zolera.com/schemas/ZSI/', 'xsd': 'http://www.w3.org/2001/XMLSchema', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
standard_ns = {'xml': 'http://www.w3.org/XML/1998/namespace', 'xmlns': 'http://www.w3.org/2000/xmlns/'}

Methods inherited from MessageInterface:
AddCallback(self, func, *arglist)
Forget(self, obj)
Known(self, obj)

 
class HTTPResponse
    Captures the information in an HTTP response message.
 
  Methods defined here:
__init__(self, response)

 
class MessageInterface
    Higher Level Interface, delegates to DOM singleton, must 
be subclassed and implement all methods that throw NotImplementedError.
 
  Methods defined here:
AddCallback(self, func, *arglist)
Forget(self, obj)
Known(self, obj)
__init__(self, sw)
Constructor, May be extended, do not override.
sw -- soapWriter instance
canonicalize(self)
canonicalize the underlying DOM, and return as string.
createAppendElement(self, namespaceURI, localName)
create and append element(namespaceURI,localName), and return
the node.
createDocument(self, namespaceURI='http://schemas.xmlsoap.org/soap/envelope/', localName='Envelope')
create Document
findNamespaceURI(self, qualifiedName)
resolvePrefix(self, prefix)
setAttributeNS(self, namespaceURI, localName, value)
set attribute (namespaceURI, localName)=value
setAttributeType(self, namespaceURI, localName)
set attribute xsi:type=(namespaceURI, localName)
setNamespaceAttribute(self, namespaceURI, prefix)
set namespace attribute xmlns:prefix=namespaceURI

 
class NamespaceError(exceptions.Exception)
    Used to indicate a Namespace Error.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ParseError(exceptions.Exception)
    Used to indicate a XML parsing error.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class RecursionError(exceptions.Exception)
    Used to indicate a HTTP redirect recursion.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class TimeoutHTTP(httplib.HTTPConnection)
    A custom http connection object that supports socket timeout.
 
  Methods defined here:
__init__(self, host, port=None, timeout=20)
connect(self)

Methods inherited from httplib.HTTPConnection:
close(self)
Close the connection to the HTTP server.
endheaders(self)
Indicate that the last header line has been sent to the server.
getresponse(self)
Get the response from the server.
putheader(self, header, value)
Send a request header line to the server.
 
For example: h.putheader('Accept', 'text/html')
putrequest(self, method, url, skip_host=0)
Send a request to the server.
 
`method' specifies an HTTP request method, e.g. 'GET'.
`url' specifies the object being requested, e.g. '/index.html'.
request(self, method, url, body=None, headers={})
Send a complete request to the server.
send(self, str)
Send `str' to the server.
set_debuglevel(self, level)

Data and other attributes inherited from httplib.HTTPConnection:
auto_open = 1
debuglevel = 0
default_port = 80
response_class = <class httplib.HTTPResponse>
strict = 0

 
class TimeoutHTTPS(httplib.HTTPSConnection)
    A custom https object that supports socket timeout. Note that this
is not really complete. The builtin SSL support in the Python socket
module requires a real socket (type) to be passed in to be hooked to
SSL. That means our fake socket won't work and our timeout hacks are
bypassed for send and recv calls. Since our hack _is_ in place at
connect() time, it should at least provide some timeout protection.
 
 
Method resolution order:
TimeoutHTTPS
httplib.HTTPSConnection
httplib.HTTPConnection

Methods defined here:
__init__(self, host, port=None, timeout=20, **kwargs)
connect(self)

Data and other attributes inherited from httplib.HTTPSConnection:
default_port = 443

Methods inherited from httplib.HTTPConnection:
close(self)
Close the connection to the HTTP server.
endheaders(self)
Indicate that the last header line has been sent to the server.
getresponse(self)
Get the response from the server.
putheader(self, header, value)
Send a request header line to the server.
 
For example: h.putheader('Accept', 'text/html')
putrequest(self, method, url, skip_host=0)
Send a request to the server.
 
`method' specifies an HTTP request method, e.g. 'GET'.
`url' specifies the object being requested, e.g. '/index.html'.
request(self, method, url, body=None, headers={})
Send a complete request to the server.
send(self, str)
Send `str' to the server.
set_debuglevel(self, level)

Data and other attributes inherited from httplib.HTTPConnection:
auto_open = 1
debuglevel = 0
response_class = <class httplib.HTTPResponse>
strict = 0

 
Functions
       
SplitQName(qname)
SplitQName(qname) -> (string, string)
 
Split Qualified Name into a tuple of len 2, consisting 
of the prefix and the local name.  
 
(prefix, localName)
 
Special Cases:
    xmlns -- (localName, 'xmlns')
    None -- (None, localName)
StringIO(...)
StringIO([s]) -- Return a StringIO-like stream for reading or writing
basejoin(base, url)
startElementNS(self, name, tagName, attrs)
startPrefixMapping(self, prefix, uri)
urlopen(url, timeout=20, redirects=None)
A minimal urlopen replacement hack that supports timeouts for http.
Note that this supports GET only.

 
Data
        DOM = <Utility.DOM instance>
START_ELEMENT = 'START_ELEMENT'
ZSI_SCHEMA_URI = 'http://www.zolera.com/schemas/ZSI/'
ident = '$Id: Utility.py 1405 2007-07-10 20:25:44Z boverhof $'
token = './'