annotate idavoll/storage.py @ 127:d3689da18ed2

Don't use encode('utf-8') on serialized XML. Return unicode strings for get_items() Rename get_items_by_ids() to get_items_by_id() as in the interface. Make purge() work. Don't return item ids when removing items.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 24 Apr 2005 17:21:43 +0000
parents 0d7b95fb2549
children b27a66637a10
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
1 from zope.interface import Interface
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
2 from twisted.words.protocols.jabber import jid
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
3
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
4 class Error(Exception):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
5 msg = None
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
6
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
7 class NodeNotFound(Error):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
8 pass
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
9
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
10 class NodeExists(Error):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
11 pass
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
12
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
13 class SubscriptionNotFound(Error):
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
14 pass
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
15
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
16 class SubscriptionExists(Error):
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
17 pass
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
18
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
19 class IStorage(Interface):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
20 """ Storage interface """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
21
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
22 def get_node(self, node_id):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
23 """ Get Node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
24
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
25 @param node_id: NodeID of the desired node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
26 @type node_id: L{str}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
27 @return: deferred that returns a L{Node} object.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
28 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
29
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
30 def get_node_ids(self):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
31 """ Return all NodeIDs.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
32
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
33 @return: deferred that returns a list of NodeIDs (L{str}).
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
34 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
35
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
36 def create_node(self, node_id, owner, config = None, type='leaf'):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
37 """ Create new node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
38
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
39 The implementation should make sure, the passed owner JID is stripped
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
40 of the resource (e.g. using C{owner.userhostJID()}).
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
41
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
42 @param node_id: NodeID of the new node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
43 @type node_id: L{str}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
44 @param owner: JID of the new nodes's owner.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
45 @type owner: L{jid.JID}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
46 @param config: Configuration
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
47 @param type: Node type. Can be either C{'leaf'} or C{'collection'}.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
48 @return: deferred that fires on creation.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
49 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
50
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
51 def delete_node(self, node_id):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
52 """ Delete a node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
53
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
54 @param node_id: NodeID of the new node.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
55 @type node_id: L{str}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
56 @return: deferred that fires on deletion.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
57 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59 def get_affiliations(self, entity):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
60 """ Get all affiliations for entity.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
61
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
62 The implementation should make sure, the passed owner JID is stripped
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
63 of the resource (e.g. using C{owner.userhostJID()}).
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
64
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
65 @param entity: JID of the entity.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
66 @type entity: L{jid.JID}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
67 @return: deferred that returns a L{list} of tuples of the form
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
68 C{(node_id, affiliation)}, where C{node_id} is of the type
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
69 L{str} and C{affiliation} is one of C{'owner'}, C{'publisher'}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
70 and C{'outcast'}.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
71 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
72
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
73 def get_subscriptions(self, entity):
111
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
74 """ Get all subscriptions for an entity.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
75
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
76 The implementation should make sure, the passed owner JID is stripped
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
77 of the resource (e.g. using C{owner.userhostJID()}).
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
78
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
79 @param entity: JID of the entity.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
80 @type entity: L{jid.JID}
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
81 @return: deferred that returns a L{list} of tuples of the form
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
82 C{(node_id, subscriber, state)}, where C{node_id} is of the
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
83 type L{str}, C{subscriber} of the type {jid.JID}, and
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
84 C{state} is C{'subscribed'} or C{'pending'}.
30c580286d27 Add documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 107
diff changeset
85 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
86
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
87
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
88 class INode(Interface):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
89 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
90 def get_type(self):
116
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
91 """ Get node's type.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
92
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
93 @return: C{'leaf'} or C{'collection'}.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
94 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
95
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
96 def get_configuration(self):
116
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
97 """ Get node's configuration.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
98
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
99 The configuration must at least have two options:
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
100 C{pubsub#persist_items}, and C{pubsub#deliver_payloads}.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
101
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
102 @return: L{dict} of configuration options.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
103 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
104
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
105 def get_meta_data(self):
116
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
106 """ Get node's meta data.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
107
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
108 The meta data must be a superset of the configuration options, and
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
109 also at least should have a C{pubsub#node_type} entry.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
110
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
111 @return: L{dict} of meta data.
06bab3d2490d Added more documentation.
Ralph Meijer <ralphm@ik.nu>
parents: 111
diff changeset
112 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
113
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
114 def set_configuration(self, options):
125
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
115 """ Set node's configuration.
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
116
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
117 The elements of {options} will set the new values for those
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
118 configuration items. This means that only changing items have to
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
119 be given.
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
120
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
121 @param options: a dictionary of configuration options.
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
122 @returns: a deferred that fires upon success.
0d7b95fb2549 Add documentation to set_configuration().
Ralph Meijer <ralphm@ik.nu>
parents: 119
diff changeset
123 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
124
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
125 def get_affiliation(self, entity):
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
126 """ Get affiliation of entity with this node.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
127
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
128 @param entity: JID of entity.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
129 @type entity: L{jid.JID}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
130 @return: deferred that returns C{'owner'}, C{'publisher'}, C{'outcast'}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
131 or C{None}.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
132 """
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
133
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
134 def get_subscription(self, subscriber):
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
135 """ Get subscription to this node of subscriber.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
136
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
137 @param subscriber: JID of the new subscriptions' entity.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
138 @type subscriber: L{jid.JID}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
139 @return: deferred that returns the subscription state (C{'subscribed'},
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
140 C{'pending'} or C{None}).
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
141 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
142
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
143 def add_subscription(self, subscriber, state):
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
144 """ Add new subscription to this node with given state.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
145
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
146 @param subscriber: JID of the new subscriptions' entity.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
147 @type subscriber: L{jid.JID}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
148 @param state: C{'subscribed'} or C{'pending'}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
149 @type state: L{str}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
150 @return: deferred that fires on subscription.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
151 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
152
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
153 def remove_subscription(self, subscriber):
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
154 """ Remove subscription to this node.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
155
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
156 @param subscriber: JID of the subscriptions' entity.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
157 @type subscriber: L{jid.JID}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
158 @return: deferred that fires on removal.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
159 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
160
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
161 def get_subscribers(self):
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
162 """ Get list of subscribers to this node.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
163
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
164 Retrieves the list of entities that have a subscription to this
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
165 node. That is, having the state C{'subscribed'}.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
166
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
167 @return: a deferred that returns a L{list} of L{jid.JID}s.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
168 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
169
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
170 def is_subscribed(self, subscriber):
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
171 """ Returns whether subscriber has a subscription to this node.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
172
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
173 Only returns C{True} when the subscription state (if present) is
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
174 C{'subscribed'}.
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
175
119
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
176 @param subscriber: JID of the subscriptions' entity.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
177 @type subscriber: L{jid.JID}
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
178 @return: deferred that returns a L{bool}.
3e7a7426f518 Added SubscriptionNotFound and SubscriptionExists errors.
Ralph Meijer <ralphm@ik.nu>
parents: 116
diff changeset
179 """
107
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
180
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
181 class ILeafNode(Interface):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
182 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
183 def store_items(self, items, publisher):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
184 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
185
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
186 def remove_items(self, item_ids):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
187 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
188
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
189 def get_items(self, max_items=None):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
190 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
191
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
192 def get_items_by_id(self, item_ids):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
193 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
194
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
195 def purge(self):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
196 """ """
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
197
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
198
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
199 class ISubscription(Interface):
d252d793f0ed Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
200 """ """