comparison idavoll/storage.py @ 111:30c580286d27

Add documentation.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 08 Apr 2005 16:30:26 +0000
parents d252d793f0ed
children 06bab3d2490d
comparison
equal deleted inserted replaced
110:7043839982ba 111:30c580286d27
1 from zope.interface import Interface 1 from zope.interface import Interface
2 from twisted.words.protocols.jabber import jid
2 3
3 class Error(Exception): 4 class Error(Exception):
4 msg = None 5 msg = None
5 6
6 class NodeNotFound(Error): 7 class NodeNotFound(Error):
10 class NodeExists(Error): 11 class NodeExists(Error):
11 pass 12 pass
12 13
13 14
14 class IStorage(Interface): 15 class IStorage(Interface):
15 """ """ 16 """ Storage interface """
16 17
17 def get_node(self, node_id): 18 def get_node(self, node_id):
18 """ """ 19 """ Get Node.
20
21 @param node_id: NodeID of the desired node.
22 @type node_id: L{str}
23 @return: deferred that returns a L{Node} object.
24 """
19 25
20 def get_node_ids(self): 26 def get_node_ids(self):
21 """ """ 27 """ Return all NodeIDs.
28
29 @return: deferred that returns a list of NodeIDs (L{str}).
30 """
22 31
23 def create_node(self, node_id, owner, config = None, type='leaf'): 32 def create_node(self, node_id, owner, config = None, type='leaf'):
24 """ """ 33 """ Create new node.
34
35 The implementation should make sure, the passed owner JID is stripped
36 of the resource (e.g. using C{owner.userhostJID()}).
37
38 @param node_id: NodeID of the new node.
39 @type node_id: L{str}
40 @param owner: JID of the new nodes's owner.
41 @type owner: L{jid.JID}
42 @param config: Configuration
43 @param type: Node type. Can be either C{'leaf'} or C{'collection'}.
44 @return: deferred that fires on creation.
45 """
25 46
26 def delete_node(self, node_id): 47 def delete_node(self, node_id):
27 """ """ 48 """ Delete a node.
49
50 @param node_id: NodeID of the new node.
51 @type node_id: L{str}
52 @return: deferred that fires on deletion.
53 """
28 54
29 def get_affiliations(self, entity): 55 def get_affiliations(self, entity):
30 """ """ 56 """ Get all affiliations for entity.
57
58 The implementation should make sure, the passed owner JID is stripped
59 of the resource (e.g. using C{owner.userhostJID()}).
60
61 @param entity: JID of the entity.
62 @type entity: L{jid.JID}
63 @return: deferred that returns a L{list} of tuples of the form
64 C{(node_id, affiliation)}, where C{node_id} is of the type
65 L{str} and C{affiliation} is one of C{'owner'}, C{'publisher'}
66 and C{'outcast'}.
67 """
31 68
32 def get_subscriptions(self, entity): 69 def get_subscriptions(self, entity):
33 """ """ 70 """ Get all subscriptions for an entity.
71
72 The implementation should make sure, the passed owner JID is stripped
73 of the resource (e.g. using C{owner.userhostJID()}).
74
75 @param entity: JID of the entity.
76 @type entity: L{jid.JID}
77 @return: deferred that returns a L{list} of tuples of the form
78 C{(node_id, subscriber, state)}, where C{node_id} is of the
79 type L{str}, C{subscriber} of the type {jid.JID}, and
80 C{state} is C{'subscribed'} or C{'pending'}.
81 """
34 82
35 83
36 class INode(Interface): 84 class INode(Interface):
37 """ """ 85 """ """
38 def get_type(self): 86 def get_type(self):