Changeset 93:8f0856ddc616 for wokkel/pubsub.py
- Timestamp:
- Feb 12, 2011, 10:58:46 PM (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/pubsub.py
r92 r93 221 221 L{Subscription}. 222 222 @type subscriptions: C{set} 223 @ivar affiliations: Affiliations to be modified, as a dictionary of entity 224 (L{JID} to affiliation (C{unicode}). 225 @type affiliations: C{dict} 223 226 """ 224 227 … … 235 238 subscriptionIdentifier = None 236 239 subscriptions = None 240 affiliations = None 237 241 238 242 # Map request iq type and subelement name to request verb … … 280 284 'delete': ['node'], 281 285 'affiliationsGet': ['nodeOrEmpty'], 282 'affiliationsSet': [ ],286 'affiliationsSet': ['nodeOrEmpty', 'affiliations'], 283 287 'subscriptionsGet': ['nodeOrEmpty'], 284 288 'subscriptionsSet': [], … … 525 529 optionsElement = verbElement.parent.addElement('options') 526 530 self._render_options(optionsElement) 531 532 533 def _parse_affiliations(self, verbElement): 534 self.affiliations = {} 535 for element in verbElement.elements(): 536 if (element.uri == NS_PUBSUB_OWNER and 537 element.name == 'affiliation'): 538 try: 539 entity = jid.internJID(element['jid']).userhostJID() 540 except KeyError: 541 raise BadRequest(text='Missing jid attribute') 542 543 if entity in self.affiliations: 544 raise BadRequest(text='Multiple affiliations for an entity') 545 546 try: 547 affiliation = element['affiliation'] 548 except KeyError: 549 raise BadRequest(text='Missing affiliation attribute') 550 551 self.affiliations[entity] = affiliation 527 552 528 553 … … 1304 1329 return message 1305 1330 1331 1332 def _toResponse_affiliationsGet(self, result, resource, request): 1333 response = domish.Element((NS_PUBSUB_OWNER, 'pubsub')) 1334 affiliations = response.addElement('affiliations') 1335 1336 if request.nodeIdentifier: 1337 affiliations['node'] = request.nodeIdentifier 1338 1339 for entity, affiliation in result.iteritems(): 1340 item = affiliations.addElement('affiliation') 1341 item['jid'] = entity.full() 1342 item['affiliation'] = affiliation 1343 1344 return response 1345 1346 1306 1347 # public methods 1307 1348
Note: See TracChangeset
for help on using the changeset viewer.