Package pyxmpp :: Module roster :: Class Roster
[hide private]

Class Roster

source code

                 object --+    
                          |    
objects.StanzaPayloadObject --+
                              |
                             Roster

Class representing XMPP-IM roster.

Iteration over Roster object iterates over roster items.

for item in roster: ... may be used to iterate over roster items, roster[jid] to get roster item by jid, jid in roster to test roster for jid presence.

Instance Methods [hide private]
 
__init__(self, node=None, server=False, strict=True)
Initialize Roster object.
source code
 
from_xml(self, node, strict=True)
Initialize Roster object from XML node.
source code
 
complete_xml_element(self, xmlnode, doc)
Complete the XML node with self content.
source code
 
__str__(self)
str(x)
source code
 
__iter__(self) source code
 
__contains__(self, jid) source code
 
__getitem__(self, jid) source code
 
get_items(self)
Return a list of items in the roster.
source code
 
get_groups(self)
Return a list of groups in the roster.
source code
 
get_items_by_name(self, name, case_sensitive=True)
Return a list of items with given name.
source code
 
get_items_by_group(self, group, case_sensitive=True)
Return a list of groups with given name.
source code
 
get_item_by_jid(self, jid)
Return roster item with given jid.
source code
 
add_item(self, item_or_jid, subscription='none', name=None, groups=(), ask=None)
Add an item to the roster.
source code
 
remove_item(self, jid)
Remove item from the roster.
source code
 
update(self, query)
Apply an update request to the roster.
source code

Inherited from objects.StanzaPayloadObject: as_xml

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
: unicode xml_element_name = 'query'
: name for the XML element provided by the class.
: unicode xml_element_namespace = 'jabber:iq:roster'
: namespace URI for the XML element provided by the class.
Instance Variables [hide private]
: dict of JID -> RosterItem items_dict
: items indexed by JID.
Properties [hide private]
  items
Return a list of items in the roster.

Inherited from object: __class__

Method Details [hide private]

__init__(self, node=None, server=False, strict=True)
(Constructor)

source code 

Initialize Roster object.

node should be an XML representation of the roster (e.g. as sent from server in response to roster request). When node is None empty roster will be created.

If server is true the object is considered server-side roster.

If strict is False, than invalid items in the XML will be ignored.

Overrides: object.__init__

from_xml(self, node, strict=True)

source code 

Initialize Roster object from XML node.

If strict is False, than invalid items in the XML will be ignored.

complete_xml_element(self, xmlnode, doc)

source code 

Complete the XML node with self content.

Should be overriden in classes derived from StanzaPayloadObject.

Parameters:
  • xmlnode (: libxml2.xmlNode) - : XML node with the element being built. It has already right name and namespace, but no attributes or content.
  • doc (: libxml2.xmlDoc) - : document to which the element belongs.
Overrides: objects.StanzaPayloadObject.complete_xml_element

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

get_items_by_name(self, name, case_sensitive=True)

source code 

Return a list of items with given name.

If case_sensitive is False the matching will be case insensitive.

get_items_by_group(self, group, case_sensitive=True)

source code 

Return a list of groups with given name.

If case_sensitive is False the matching will be case insensitive.

get_item_by_jid(self, jid)

source code 
Return roster item with given jid.
Raises:
  • KeyError - if the item is not found.

add_item(self, item_or_jid, subscription='none', name=None, groups=(), ask=None)

source code 

Add an item to the roster.

The item_or_jid argument may be a RosterItem object or a JID. If it is a JID then subscription, name, groups and ask may also be specified.

update(self, query)

source code 

Apply an update request to the roster.

query should be a query included in a "roster push" IQ received.


Property Details [hide private]

items

Return a list of items in the roster.
Get Method:
get_items(self) - Return a list of items in the roster.