xmlstream
index

xmlstream.py provides simple functionality for implementing
XML stream based network protocols. It is used as a  base
for jabber.py.
 
xmlstream.py manages the network connectivity and xml parsing
of the stream. When a complete 'protocol element' ( meaning a
complete child of the xmlstreams root ) is parsed the dipatch
method is called with a 'Node' instance of this structure.
The Node class is a very simple XML DOM like class for
manipulating XML documents or 'protocol elements' in this
case.

 
Modules
            
re
socket
sys
time
xml
xmllib

 
Classes
            
Client
Node
NodeBuilder
Server
Stream
error

 
class Client
       
  
DEBUG(self, txt)
__init__(self, host, port, namespace, debug=1, log=None)
_handle_data(self, data)
XML Parser callback
_unknown_endtag(self, tag)
XML Parser callback
_unknown_starttag(self, tag, attrs)
XML Parser callback
connect(self)
Attempt to connect to specified host
disconnect(self)
Close the stream and socket
disconnected(self)
Called when a Network Error or disconnection occurs.
Designed to be overidden
dispatch(self, nodes, depth=0)
Overide with the method you want to called with
a node structure of a 'protocol element.
getStreamID(self)
Returns the streams ID
log(self, data, inout='')
Logs data to the specified filehandle. Data is time stamped
and prefixed with inout
process(self, timeout)
read(self)
Reads incoming data. Called by process() so nonblocking
write(self, data_out='')
Writes raw outgoing data. blocks

 
class Node
      A simple XML DOM like class
 
  
__init__(self, tag='', parent=None, attrs=None)
__str__(self)
_xmlnode2str(self, parent=None)
Returns an xml ( string ) representation of the node
and it children
getAttr(self, key)
Get a value for the nodes named attribute.
getChildren(self)
Returns a nodes children
getData(self)
Return the nodes textual data
getName(self)
Set the nodes tag name.
getNamespace(self)
Returns the nodes namespace.
getParent(self)
return the nodes parent node.
getTag(self, name)
Returns a child node with tag name name. Returns None
if not found.
insertData(self, data)
Set the nodes textual data
insertNode(self, node)
Add a child node to the node
insertTag(self, name)
Add a child tag of name 'name' to the node
insertXML(self, xml_str)
Add raw xml as a child of the node
putAttr(self, key, val)
Add a name/value attribute to the node.
putData(self, data)
Set the nodes textual data
setName(self, val)
Set the nodes tag name.
setNamespace(self, namespace)
Set the nodes namespace.
setParent(self, node)
Set the nodes parent node.

 
class NodeBuilder
      builds a 'minidom' from data parsed to it. Primarily for insertXML
method of Node
 
  
__init__(self, data)
dispatch(self, dom)
getDom(self)
handle_data(self, data)
unknown_endtag(self, tag)
unknown_starttag(self, tag, attrs)

 
class Server
       
  

 
class Stream
       
  

 
class error
       
  
__init__(self, value)
__str__(self)

 
Functions
            
XMLescape(txt)
Escape XML entities
XMLunescape(txt)
Unescape XML entities
select(...)
select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)
 
Wait until one or more file descriptors are ready for some kind of I/O.
The first three arguments are lists of file descriptors to be waited for:
rlist -- wait until ready for reading
wlist -- wait until ready for writing
xlist -- wait for an ``exceptional condition''
If only one kind of condition is required, pass [] for the other lists.
A file descriptor is either a socket or file object, or a small integer
gotten from a fileno() method call on one of those.
 
The optional 4th argument specifies a timeout in seconds; it may be
a floating point number to specify fractions of seconds.  If it is absent
or None, the call will never time out.
 
The return value is a tuple of three lists corresponding to the first three
arguments; each contains the subset of the corresponding file descriptors
that are ready.
 
*** IMPORTANT NOTICE ***
On Windows, only sockets are supported; on Unix, all file descriptors.

 
Data
             False = 0
True = 1
VERSION = 0.20000000000000001
__file__ = './xmlstream.pyc'
__name__ = 'xmlstream'