comparison idavoll/storage.py @ 128:b27a66637a10

Add more documentation.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 24 Apr 2005 17:23:12 +0000
parents 0d7b95fb2549
children 812300cdbc22
comparison
equal deleted inserted replaced
127:d3689da18ed2 128:b27a66637a10
1 from zope.interface import Interface 1 from zope.interface import Interface
2 from twisted.words.protocols.jabber import jid 2 from twisted.words.protocols.jabber import jid
3 from twisted.xish import domish
3 4
4 class Error(Exception): 5 class Error(Exception):
5 msg = None 6 msg = None
6 7
7 class NodeNotFound(Error): 8 class NodeNotFound(Error):
12 13
13 class SubscriptionNotFound(Error): 14 class SubscriptionNotFound(Error):
14 pass 15 pass
15 16
16 class SubscriptionExists(Error): 17 class SubscriptionExists(Error):
18 pass
19
20 class ItemNotFound(Error):
17 pass 21 pass
18 22
19 class IStorage(Interface): 23 class IStorage(Interface):
20 """ Storage interface """ 24 """ Storage interface """
21 25
84 C{state} is C{'subscribed'} or C{'pending'}. 88 C{state} is C{'subscribed'} or C{'pending'}.
85 """ 89 """
86 90
87 91
88 class INode(Interface): 92 class INode(Interface):
89 """ """ 93 """ Interface to the class of objects that represent nodes. """
94
90 def get_type(self): 95 def get_type(self):
91 """ Get node's type. 96 """ Get node's type.
92 97
93 @return: C{'leaf'} or C{'collection'}. 98 @return: C{'leaf'} or C{'collection'}.
94 """ 99 """
177 @type subscriber: L{jid.JID} 182 @type subscriber: L{jid.JID}
178 @return: deferred that returns a L{bool}. 183 @return: deferred that returns a L{bool}.
179 """ 184 """
180 185
181 class ILeafNode(Interface): 186 class ILeafNode(Interface):
182 """ """ 187 """ Interface to the class of objects that represent leaf nodes. """
188
183 def store_items(self, items, publisher): 189 def store_items(self, items, publisher):
184 """ """ 190 """ Store items in persistent storage for later retrieval.
191
192 @param items: The list of items to be stored. Each item is the
193 L{domish} representation of the XML fragment as defined
194 for C{<item/>} in the
195 C{http://jabber.org/protocol/pubsub} namespace.
196 @type items: L{list} of {domish.Element}
197 @param publisher: JID of the publishing entity.
198 @type publisher: L{jid.JID}
199 @return: deferred that fires upon success.
200 """
185 201
186 def remove_items(self, item_ids): 202 def remove_items(self, item_ids):
187 """ """ 203 """ Remove items by id
204
205 @param item_ids: L{list} of item ids.
206 @return: deferred that fires when all given items were deleted, or
207 a failure if one of them was not found.
208 """
188 209
189 def get_items(self, max_items=None): 210 def get_items(self, max_items=None):
190 """ """ 211 """ Get items.
212
213 If C{max_items} is not given, all items in the node are returned,
214 just like C{get_items_by_id}. Otherwise, C{max_items} limits
215 the returned items to a maximum of that number of most recently
216 published items.
217
218 @param max_items: if given, a natural number (>0) that limits the
219 returned number of items.
220 @return: deferred that fires with a C{list} of found items.
221 """
191 222
192 def get_items_by_id(self, item_ids): 223 def get_items_by_id(self, item_ids):
193 """ """ 224 """ Get items by item id.
225
226 Each item in the returned list is a unicode string that
227 represent the XML of the item as it was published, including the
228 item wrapper with item id.
229
230 @param item_ids: L{list} of item ids.
231 @return: deferred that fires with a C{list} of found items.
232 """
194 233
195 def purge(self): 234 def purge(self):
196 """ """ 235 """ Purge node of all items in persistent storage.
236
237 @return: deferred that fires when the node has been purged.
238 """
197 239
198 240
199 class ISubscription(Interface): 241 class ISubscription(Interface):
200 """ """ 242 """ """