comparison idavoll/backend.py @ 106:dc36882d2620

Also move from twisted.python.components to zope.interface.Interface
author Ralph Meijer <ralphm@ik.nu>
date Fri, 08 Apr 2005 10:08:41 +0000
parents 8d8946e67fcb
children 1c18759d2afb
comparison
equal deleted inserted replaced
105:8d8946e67fcb 106:dc36882d2620
1 from twisted.words.protocols.jabber import jid 1 from twisted.words.protocols.jabber import jid
2 from twisted.python import components
3 from twisted.application import service 2 from twisted.application import service
4 from twisted.xish import utility 3 from twisted.xish import utility
5 from twisted.internet import defer 4 from twisted.internet import defer
6 from zope.interface import implements 5 from zope.interface import Interface, implements
7 import sha 6 import sha
8 import time 7 import time
9 8
10 class Error(Exception): 9 class Error(Exception):
11 msg = '' 10 msg = ''
35 pass 34 pass
36 35
37 class NotSubscribed(Error): 36 class NotSubscribed(Error):
38 pass 37 pass
39 38
40 class IBackendService(components.Interface): 39 class IBackendService(Interface):
41 """ Interface to a backend service of a pubsub service. """ 40 """ Interface to a backend service of a pubsub service. """
42 41
43 def get_supported_affiliations(self): 42 def get_supported_affiliations(self):
44 """ Reports the list of supported affiliation types. 43 """ Reports the list of supported affiliation types.
45 44
46 @return: a list of supported affiliation types. 45 @return: a list of supported affiliation types.
47 """ 46 """
48 47
49 class INodeCreationService(components.Interface): 48 class INodeCreationService(Interface):
50 """ A service for creating nodes """ 49 """ A service for creating nodes """
51 50
52 def create_node(self, node_id, requestor): 51 def create_node(self, node_id, requestor):
53 """ Create a node. 52 """ Create a node.
54 53
55 @return: a deferred that fires when the node has been created. 54 @return: a deferred that fires when the node has been created.
56 """ 55 """
57 56
58 class INodeDeletionService(components.Interface): 57 class INodeDeletionService(Interface):
59 """ A service for deleting nodes. """ 58 """ A service for deleting nodes. """
60 59
61 def register_pre_delete(self, pre_delete_fn): 60 def register_pre_delete(self, pre_delete_fn):
62 """ Register a callback that is called just before a node deletion. 61 """ Register a callback that is called just before a node deletion.
63 62
87 """ Delete a node. 86 """ Delete a node.
88 87
89 @return: a deferred that fires when the node has been deleted. 88 @return: a deferred that fires when the node has been deleted.
90 """ 89 """
91 90
92 class IPublishService(components.Interface): 91 class IPublishService(Interface):
93 """ A service for publishing items to a node. """ 92 """ A service for publishing items to a node. """
94 93
95 def publish(self, node_id, items, requestor): 94 def publish(self, node_id, items, requestor):
96 """ Publish items to a pubsub node. 95 """ Publish items to a pubsub node.
97 96
98 @return: a deferred that fires when the items have been published. 97 @return: a deferred that fires when the items have been published.
99 """ 98 """
100 class INotificationService(components.Interface): 99 class INotificationService(Interface):
101 """ A service for notification of published items. """ 100 """ A service for notification of published items. """
102 101
103 def register_notifier(self, observerfn, *args, **kwargs): 102 def register_notifier(self, observerfn, *args, **kwargs):
104 """ Register callback which is called for notification. """ 103 """ Register callback which is called for notification. """
105 104
106 def get_notification_list(self, node_id, items): 105 def get_notification_list(self, node_id, items):
107 pass 106 pass
108 107
109 class ISubscriptionService(components.Interface): 108 class ISubscriptionService(Interface):
110 """ A service for managing subscriptions. """ 109 """ A service for managing subscriptions. """
111 110
112 def subscribe(self, node_id, subscriber, requestor): 111 def subscribe(self, node_id, subscriber, requestor):
113 """ Request the subscription of an entity to a pubsub node. 112 """ Request the subscription of an entity to a pubsub node.
114 113
130 be raised. 129 be raised.
131 130
132 @return: a deferred that fires when unsubscription is complete. 131 @return: a deferred that fires when unsubscription is complete.
133 """ 132 """
134 133
135 class IAffiliationsService(components.Interface): 134 class IAffiliationsService(Interface):
136 """ A service for retrieving the affiliations with this pubsub service. """ 135 """ A service for retrieving the affiliations with this pubsub service. """
137 136
138 def get_affiliations(self, entity): 137 def get_affiliations(self, entity):
139 """ Report the list of current affiliations with this pubsub service. 138 """ Report the list of current affiliations with this pubsub service.
140 139
144 143
145 @return: a deferred that returns the list of all current affiliations 144 @return: a deferred that returns the list of all current affiliations
146 and subscriptions. 145 and subscriptions.
147 """ 146 """
148 147
149 class IRetractionService(components.Interface): 148 class IRetractionService(Interface):
150 """ A service for retracting published items """ 149 """ A service for retracting published items """
151 150
152 def retract_item(self, node_id, item_id, requestor): 151 def retract_item(self, node_id, item_id, requestor):
153 """ Removes item in node from persistent storage """ 152 """ Removes item in node from persistent storage """
154 153
155 def purge_node(self, node_id, requestor): 154 def purge_node(self, node_id, requestor):
156 """ Removes all items in node from persistent storage """ 155 """ Removes all items in node from persistent storage """
157 156
158 class IItemRetrievalService(components.Interface): 157 class IItemRetrievalService(Interface):
159 """ A service for retrieving previously published items. """ 158 """ A service for retrieving previously published items. """
160 159
161 def get_items(self, node_id, requestor, max_items=None, item_ids=[]): 160 def get_items(self, node_id, requestor, max_items=None, item_ids=[]):
162 """ Retrieve items from persistent storage 161 """ Retrieve items from persistent storage
163 162