Mercurial > libervia-pubsub
annotate idavoll/backend.py @ 137:aca904a41a43
Discover client_encoding parameter to pyPgSQL.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Mon, 25 Apr 2005 12:58:59 +0000 |
parents | 1c18759d2afb |
children | 753b8432460f |
rev | line source |
---|---|
108
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
1 from zope.interface import Interface |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
2 import storage |
2 | 3 |
24
4f3bbefc6fad
Moved memory backend to its own file.
Ralph Meijer <ralphm@ik.nu>
parents:
23
diff
changeset
|
4 class Error(Exception): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
5 msg = '' |
1 | 6 |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
7 def __str__(self): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
8 return self.msg |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
9 |
24
4f3bbefc6fad
Moved memory backend to its own file.
Ralph Meijer <ralphm@ik.nu>
parents:
23
diff
changeset
|
10 class NotAuthorized(Error): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
11 pass |
20
eddea65d1032
Added two exceptions: NoInstantNodes and NodeExists.
Ralph Meijer <ralphm@ik.nu>
parents:
18
diff
changeset
|
12 |
24
4f3bbefc6fad
Moved memory backend to its own file.
Ralph Meijer <ralphm@ik.nu>
parents:
23
diff
changeset
|
13 class PayloadExpected(Error): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
14 msg = 'Payload expected' |
15 | 15 |
24
4f3bbefc6fad
Moved memory backend to its own file.
Ralph Meijer <ralphm@ik.nu>
parents:
23
diff
changeset
|
16 class NoPayloadAllowed(Error): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
17 msg = 'No payload allowed' |
2 | 18 |
24
4f3bbefc6fad
Moved memory backend to its own file.
Ralph Meijer <ralphm@ik.nu>
parents:
23
diff
changeset
|
19 class NoInstantNodes(Error): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
20 pass |
23
884268687229
Simplify call chain by mapping incoming requests directly to method
Ralph Meijer <ralphm@ik.nu>
parents:
20
diff
changeset
|
21 |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
22 class NotImplemented(Error): |
34 | 23 pass |
24 | |
25 class NotSubscribed(Error): | |
26 pass | |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
27 |
108
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
28 class InvalidConfigurationOption(Error): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
29 msg = 'Invalid configuration option' |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
30 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
31 class InvalidConfigurationValue(Error): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
32 msg = 'Bad configuration value' |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
33 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
34 class IBackendService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
35 """ Interface to a backend service of a pubsub service. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
36 |
108
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
37 def __init__(self, storage): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
38 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
39 @param storage: L{storage} object. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
40 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
41 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
42 def supports_publisher_affiliation(self): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
43 """ Reports if the backend supports the publisher affiliation. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
44 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
45 @rtype: C{bool} |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
46 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
47 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
48 def supports_outcast_affiliation(self): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
49 """ Reports if the backend supports the publisher affiliation. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
50 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
51 @rtype: C{bool} |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
52 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
53 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
54 def supports_persistent_items(self): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
55 """ Reports if the backend supports persistent items. |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
56 |
108
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
57 @rtype: C{bool} |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
58 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
59 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
60 def get_node_type(self, node_id): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
61 """ Return type of a node. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
62 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
63 @return: a deferred that returns either 'leaf' or 'collection' |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
64 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
65 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
66 def get_nodes(self): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
67 """ Returns list of all nodes. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
68 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
69 @return: a deferred that returns a C{list} of node ids. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
70 """ |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
71 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
72 def get_node_meta_data(self, node_id): |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
73 """ Return meta data for a node. |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
74 |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
75 @return: a deferred that returns a C{list} of C{dict}s with the |
1c18759d2afb
Moved two errors to storage.py.
Ralph Meijer <ralphm@ik.nu>
parents:
106
diff
changeset
|
76 metadata. |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
77 """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
78 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
79 class INodeCreationService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
80 """ A service for creating nodes """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
81 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
82 def create_node(self, node_id, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
83 """ Create a node. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
84 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
85 @return: a deferred that fires when the node has been created. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
86 """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
87 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
88 class INodeDeletionService(Interface): |
90
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
89 """ A service for deleting nodes. """ |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
90 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
91 def register_pre_delete(self, pre_delete_fn): |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
92 """ Register a callback that is called just before a node deletion. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
93 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
94 The function C{pre_deleted_fn} is added to a list of functions |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
95 to be called just before deletion of a node. The callback |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
96 C{pre_delete_fn} is called with the C{node_id} that is about to be |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
97 deleted and should return a deferred that returns a list of deferreds |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
98 that are to be fired after deletion. The backend collects the lists |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
99 from all these callbacks before actually deleting the node in question. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
100 After deletion all collected deferreds are fired to do post-processing. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
101 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
102 The idea is that you want to be able to collect data from the |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
103 node before deleting it, for example to get a list of subscribers |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
104 that have to be notified after the node has been deleted. To do this, |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
105 C{pre_delete_fn} fetches the subscriber list and passes this |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
106 list to a callback attached to a deferred that it sets up. This |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
107 deferred is returned in the list of deferreds. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
108 """ |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
109 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
110 def get_subscribers(self, node_id): |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
111 """ Get node subscriber list. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
112 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
113 @return: a deferred that fires with the list of subscribers. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
114 """ |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
115 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
116 def delete_node(self, node_id, requestor): |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
117 """ Delete a node. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
118 |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
119 @return: a deferred that fires when the node has been deleted. |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
120 """ |
59378610b16e
Implement node purging and node deletion.
Ralph Meijer <ralphm@ik.nu>
parents:
85
diff
changeset
|
121 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
122 class IPublishService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
123 """ A service for publishing items to a node. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
124 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
125 def publish(self, node_id, items, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
126 """ Publish items to a pubsub node. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
127 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
128 @return: a deferred that fires when the items have been published. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
129 """ |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
130 class INotificationService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
131 """ A service for notification of published items. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
132 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
133 def register_notifier(self, observerfn, *args, **kwargs): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
134 """ Register callback which is called for notification. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
135 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
136 def get_notification_list(self, node_id, items): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
137 pass |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
138 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
139 class ISubscriptionService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
140 """ A service for managing subscriptions. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
141 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
142 def subscribe(self, node_id, subscriber, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
143 """ Request the subscription of an entity to a pubsub node. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
144 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
145 Depending on the node's configuration and possible business rules, the |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
146 C{subscriber} is added to the list of subscriptions of the node with id |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
147 C{node_id}. The C{subscriber} might be different from the C{requestor}, |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
148 and if the C{requestor} is not allowed to subscribe this entity an |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
149 exception should be raised. |
59
0fa161c00ed9
Use jid.JIDs everywhere in the backend.
Ralph Meijer <ralphm@ik.nu>
parents:
53
diff
changeset
|
150 |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
151 @return: a deferred that returns the subscription state |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
152 """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
153 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
154 def unsubscribe(self, node_id, subscriber, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
155 """ Cancel the subscription of an entity to a pubsub node. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
156 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
157 The subscription of C{subscriber} is removed from the list of |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
158 subscriptions of the node with id C{node_id}. If the C{requestor} |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
159 is not allowed to unsubscribe C{subscriber}, an an exception should |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
160 be raised. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
161 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
162 @return: a deferred that fires when unsubscription is complete. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
163 """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
164 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
165 class IAffiliationsService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
166 """ A service for retrieving the affiliations with this pubsub service. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
167 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
168 def get_affiliations(self, entity): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
169 """ Report the list of current affiliations with this pubsub service. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
170 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
171 Report the list of the current affiliations with all nodes within this |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
172 pubsub service, along with subscriptions to such nodes, for the |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
173 C{entity}. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
174 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
175 @return: a deferred that returns the list of all current affiliations |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
176 and subscriptions. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
177 """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
178 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
179 class IRetractionService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
180 """ A service for retracting published items """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
181 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
182 def retract_item(self, node_id, item_id, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
183 """ Removes item in node from persistent storage """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
184 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
185 def purge_node(self, node_id, requestor): |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
186 """ Removes all items in node from persistent storage """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
187 |
106
dc36882d2620
Also move from twisted.python.components to zope.interface.Interface
Ralph Meijer <ralphm@ik.nu>
parents:
105
diff
changeset
|
188 class IItemRetrievalService(Interface): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
189 """ A service for retrieving previously published items. """ |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
190 |
80
ec354aab3949
Implemented ItemRetrievalService.
Ralph Meijer <ralphm@ik.nu>
parents:
72
diff
changeset
|
191 def get_items(self, node_id, requestor, max_items=None, item_ids=[]): |
29
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
192 """ Retrieve items from persistent storage |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
193 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
194 If C{max_items} is given, return the C{max_items} last published |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
195 items, else if C{item_ids} is not empty, return the items requested. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
196 If neither is given, return all items. |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
197 |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
198 @return: a deferred that returns the requested items |
d4fc29bb5381
Define interfaces of blocks of functionality.
Ralph Meijer <ralphm@ik.nu>
parents:
24
diff
changeset
|
199 """ |