Package pyxmpp :: Module roster :: Class Roster
[show private | hide private]
[frames | no frames]

Type Roster

         object --+    
                  |    
StanzaPayloadObject --+
                      |
                     Roster


Class representing XMPP-IM roster.
Method Summary
  __init__(self, node, server, strict)
Initialize Roster object.
  __str__(self)
  add_item(self, item_or_jid, subscription, name, groups, ask)
Add an item to the roster.
  complete_xml_element(self, xmlnode, doc)
Complete the XML node with self content.
  from_xml(self, node, strict)
Initialize Roster object from XML node.
  get_groups(self)
Return a list of groups in the roster.
  get_item_by_jid(self, jid)
Return roster item with given jid.
  get_items(self)
Return a list of items in the roster.
  get_items_by_group(self, group, case_sensitive)
Return a list of groups with given name.
  get_items_by_name(self, name, case_sensitive)
Return a list of items with given name.
  remove_item(self, jid)
Remove item from the roster.
  update(self, query)
Apply an update request to the roster.
    Inherited from StanzaPayloadObject
libxml2.xmlNode or libxml2.xmlDoc as_xml(self, parent, doc)
Get the XML representation of self.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Instance Variable Summary
dict of JID -> RosterItem items_dict: items indexed by JID.

Class Variable Summary
unicode xml_element_name: name for the XML element provided by the class.
unicode xml_element_namespace: namespace URI for the XML element provided by the class.

Method Details

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

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:
__builtin__.object.__init__

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

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.

complete_xml_element(self, xmlnode, doc)

Complete the XML node with self content.

Should be overriden in classes derived from StanzaPayloadObject.

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

from_xml(self, node, strict=True)

Initialize Roster object from XML node.

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

get_groups(self)

Return a list of groups in the roster.

get_item_by_jid(self, jid)

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

get_items(self)

Return a list of items in the roster.

get_items_by_group(self, group, case_sensitive=True)

Return a list of groups with given name.

If case_sensitive is False the matching will be case insensitive.

get_items_by_name(self, name, case_sensitive=True)

Return a list of items with given name.

If case_sensitive is False the matching will be case insensitive.

remove_item(self, jid)

Remove item from the roster.

update(self, query)

Apply an update request to the roster.

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


Instance Variable Details

items_dict

items indexed by JID.
Type:
dict of JID -> RosterItem

Class Variable Details

xml_element_name

name for the XML element provided by the class.
Type:
unicode
Value:
'query'                                                                

xml_element_namespace

namespace URI for the XML element provided by the class.
Type:
unicode
Value:
'jabber:iq:roster'