comparison sat_pubsub/backend.py @ 364:8bd8be6815ab

completed docstrings + use short notation for sets
author Arnaud Joset <info@agayon.be>
date Fri, 03 Nov 2017 13:59:54 +0100
parents a98b3d52c2ff
children 9fbb31ce495b
comparison
equal deleted inserted replaced
363:a98b3d52c2ff 364:8bd8be6815ab
274 return (access_model, item_config) 274 return (access_model, item_config)
275 275
276 def parseCategories(self, item_elt): 276 def parseCategories(self, item_elt):
277 """Check if item contain an atom entry, and parse categories if possible 277 """Check if item contain an atom entry, and parse categories if possible
278 278
279 @param item (domish.Element): item to parse 279 @param item_elt (domish.Element): item to parse
280 @return (list): list of found categories 280 @return (list): list of found categories
281 """ 281 """
282 categories = [] 282 categories = []
283 try: 283 try:
284 entry_elt = item_elt.elements(const.NS_ATOM, "entry").next() 284 entry_elt = item_elt.elements(const.NS_ATOM, "entry").next()
536 """retrieve subscriptions of an entity 536 """retrieve subscriptions of an entity
537 537
538 @param requestor(jid.JID): entity who want to check subscriptions 538 @param requestor(jid.JID): entity who want to check subscriptions
539 @param nodeIdentifier(unicode, None): identifier of the node 539 @param nodeIdentifier(unicode, None): identifier of the node
540 node to get all subscriptions of a service 540 node to get all subscriptions of a service
541 @param pep(bool): True if it's a PEP request
542 @param recipient(jid.JID, None): recipient of the PEP request
541 """ 543 """
542 return self.storage.getSubscriptions(requestor, nodeIdentifier, pep, recipient) 544 return self.storage.getSubscriptions(requestor, nodeIdentifier, pep, recipient)
543 545
544 def supportsAutoCreate(self): 546 def supportsAutoCreate(self):
545 return True 547 return True
625 """set or remove Schema of a node 627 """set or remove Schema of a node
626 628
627 @param nodeIdentifier(unicode): identifier of the pubusb node 629 @param nodeIdentifier(unicode): identifier of the pubusb node
628 @param schema(domish.Element, None): schema to set 630 @param schema(domish.Element, None): schema to set
629 None to remove schema 631 None to remove schema
632 @param requestor(jid.JID): entity doing the request
633 @param pep(bool): True if it's a PEP request
634 @param recipient(jid.JID, None): recipient of the PEP request
630 """ 635 """
631 if not nodeIdentifier: 636 if not nodeIdentifier:
632 return defer.fail(error.NoRootNode()) 637 return defer.fail(error.NoRootNode())
633 638
634 d = self.storage.getNode(nodeIdentifier, pep, recipient) 639 d = self.storage.getNode(nodeIdentifier, pep, recipient)
1260 self.features.append("publisher-affiliation") 1265 self.features.append("publisher-affiliation")
1261 1266
1262 if self.backend.supportsGroupBlog(): 1267 if self.backend.supportsGroupBlog():
1263 self.features.append("groupblog") 1268 self.features.append("groupblog")
1264 1269
1270
1265 # if self.backend.supportsPublishModel(): #XXX: this feature is not really described in XEP-0060, we just can see it in examples 1271 # if self.backend.supportsPublishModel(): #XXX: this feature is not really described in XEP-0060, we just can see it in examples
1266 # self.features.append("publish_model") # but it's necessary for microblogging comments (see XEP-0277) 1272 # self.features.append("publish_model") # but it's necessary for microblogging comments (see XEP-0277)
1267 1273
1268 def getFullItem(self, item_data): 1274 def getFullItem(self, item_data):
1269 """ Attach item configuration to this item 1275 """ Attach item configuration to this item
1293 # TODO: same thing for getItems 1299 # TODO: same thing for getItems
1294 1300
1295 for owner_jid in owners: 1301 for owner_jid in owners:
1296 notifications_filtered.append( 1302 notifications_filtered.append(
1297 (owner_jid, 1303 (owner_jid,
1298 set([pubsub.Subscription(node.nodeIdentifier, 1304 {pubsub.Subscription(node.nodeIdentifier,
1299 owner_jid, 1305 owner_jid,
1300 'subscribed')]), 1306 'subscribed')},
1301 [self.getFullItem(item_data) for item_data in items_data])) 1307 [self.getFullItem(item_data) for item_data in items_data]))
1302 1308
1303 if pep: 1309 if pep:
1304 defer.returnValue(self.backend.privilege.notifyPublish( 1310 defer.returnValue(self.backend.privilege.notifyPublish(
1305 recipient, 1311 recipient,
1323 #we add the owners 1329 #we add the owners
1324 1330
1325 for owner_jid in owners: 1331 for owner_jid in owners:
1326 notifications_filtered.append( 1332 notifications_filtered.append(
1327 (owner_jid, 1333 (owner_jid,
1328 set([pubsub.Subscription(node.nodeIdentifier, 1334 {pubsub.Subscription(node.nodeIdentifier,
1329 owner_jid, 1335 owner_jid,
1330 'subscribed')]), 1336 'subscribed')},
1331 [item_data.item for item_data in items_data])) 1337 [item_data.item for item_data in items_data]))
1332 1338
1333 if pep: 1339 if pep:
1334 return self.backend.privilege.notifyRetract( 1340 return self.backend.privilege.notifyRetract(
1335 recipient, 1341 recipient,