Package archipelcore :: Module pubsub :: Class TNPubSubNode
[hide private]
[frames] | no frames]

Class TNPubSubNode

source code

Instance Methods [hide private]
 
__init__(self, xmppclient, pubsubserver, nodename)
Initialize the TNPubSubNode.
source code
Boolean
recover(self, wait=False)
Get the current pubsub node and wait for response.
source code
Boolean
retrieve_items(self, callback=None, wait=False)
Retrieve or update the content of the node.
source code
Boolean
create(self, callback=None, wait=False)
Create node on server if not exists.
source code
Boolean
delete(self, callback=None, wait=False)
Delete the node from server if exists.
source code
Boolean
configure(self, options, callback=None, wait=False)
Configure the node.
source code
list
get_items(self)
Return an array of all items.
source code
 
get_item(self, item_id)
Return the item with the given item id
source code
 
add_item(self, itemcontentnode, callback=None, wait=False)
Add a leaf item xmpp.node to the node and will trigger callback if any on server answer.
source code
 
remove_item(self, item_id, callback=None, user_info=None, wait=False)
Remove an item according to its ID.
source code
 
retrieve_subscriptions(self, callback=None, wait=False)
Recover the subscriptions
source code
 
subscribe(self, jid, callback, unique=True, wait=False)
Subscribe to the node.
source code
 
_on_pubsub_event(self, conn, event)
Trigger the callback for events.
source code
 
unsubscribe(self, jid, subID, callback=None, wait=False)
Unsubscribe from a node.
source code
 
fetch_affiliations(self, callback=None, wait=False)
fetch the affiliations for the node
source code
 
set_affiliation(self, jid, affiliation, callback=None, wait=False)
set an affiliation for the node
source code
Method Details [hide private]

__init__(self, xmppclient, pubsubserver, nodename)
(Constructor)

source code 

Initialize the TNPubSubNode.

Parameters:
  • xmppclient (xmpp.Dispatcher) - the xmppclient connection to user
  • xmppclient (xmpp.Dispatcher) - the string containing the JID of the pubsub server
  • nodename (string) - the name of the pubsub node
  • pubsubserver (string)

recover(self, wait=False)

source code 

Get the current pubsub node and wait for response. If not already recovered, ask to server.

Parameters:
  • wait (Boolean) - if True, recovering will be blockant (IE, execution interrupted until recovering)
Returns: Boolean
True in case of success

retrieve_items(self, callback=None, wait=False)

source code 

Retrieve or update the content of the node.

Parameters:
  • wait (Boolean) - if True, recovering will be blockant (IE, execution interrupted until recovering)
Returns: Boolean
True in case of success

create(self, callback=None, wait=False)

source code 

Create node on server if not exists.

Parameters:
  • wait (Boolean) - if True, recovering will be blockant (IE, execution interrupted until recovering)
Returns: Boolean
True in case of success

delete(self, callback=None, wait=False)

source code 

Delete the node from server if exists.

Parameters:
  • wait (Boolean) - if True, recovering will be blockant (IE, execution interrupted until recovering)
Returns: Boolean
True in case of success

configure(self, options, callback=None, wait=False)

source code 

Configure the node.

Parameters:
  • options (dict) - dictionary containing options: value for the pubsub configuration
  • wait (Boolean) - if True, recovering will be blockant (IE, execution interrupted until recovering)
Returns: Boolean
True in case of success

get_items(self)

source code 

Return an array of all items.

Returns: list
list of pubsub's xmpp.Nonde

get_item(self, item_id)

source code 

Return the item with the given item id

Parameters:
  • item_id (string) - the pubsub node id

add_item(self, itemcontentnode, callback=None, wait=False)

source code 

Add a leaf item xmpp.node to the node and will trigger callback if any on server answer.

Parameters:
  • itemcontentnode (xmpp.Node) - the node to publish on the pubsub
  • callback (function) - if not None, callback will be called after publication

remove_item(self, item_id, callback=None, user_info=None, wait=False)

source code 

Remove an item according to its ID.

Parameters:
  • item_id (string) - the id of the node to remove
  • callback (function) - if not None, callback will be called after retraction
  • user_info (Object) - random info to pass to the callback

retrieve_subscriptions(self, callback=None, wait=False)

source code 

Recover the subscriptions

Parameters:
  • callback (function) - if not None, callback will be called after retrieval
  • wait (Boolean) - if True, action will be done in sync mode

subscribe(self, jid, callback, unique=True, wait=False)

source code 

Subscribe to the node.

Parameters:
  • jid (xmpp.Protocol.JID) - the JID of the subscriber
  • callback (function) - the callback that will be called when an item is published
  • unique (Boolean) - if True, it will subscribe only if no subscription is already done
  • wait (Boolean) - if True, action will be done in sync mode

unsubscribe(self, jid, subID, callback=None, wait=False)

source code 

Unsubscribe from a node.

Parameters:
  • jid (xmpp.JID) - the JID of the entity to unsubscribe
  • subID (String) - the subscription ID to remove. If None, all subscriptions will be removed
  • callback - the callback that will be called when an item is published
  • wait (Boolean) - if True, action will be done in sync mode

fetch_affiliations(self, callback=None, wait=False)

source code 

fetch the affiliations for the node

Parameters:
  • callback (Function) - the callback function
  • wait (Boolean) - if true, wait for answer

set_affiliation(self, jid, affiliation, callback=None, wait=False)

source code 

set an affiliation for the node

Parameters:
  • jid (xmpp.JID) - the jid to change affiliation
  • affiliation (String) - the affiliation
  • callback (Function) - the callback function
  • wait (Boolean) - if true, wait for answer