diff sat_pubsub/pgsql_storage.py @ 263:9dfd3890e646

added the constant FLAG_RETRACT_ALLOW_PUBLISHER to allow a publisher to retract an item he has published in a node of "open" publish model.
author souliane <souliane@mailoo.org>
date Fri, 21 Feb 2014 16:10:11 +0100
parents 7b821432d012
children 89493845d3dd
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Fri Dec 06 00:37:08 2013 +0100
+++ b/sat_pubsub/pgsql_storage.py	Fri Feb 21 16:10:11 2014 +0100
@@ -720,6 +720,20 @@
                        (self.nodeIdentifier,))
 
 
+    def filterItemsWithPublisher(self, itemIdentifiers, requestor):
+        return self.dbpool.runInteraction(self._filterItemsWithPublisher, itemIdentifiers, requestor)
+
+    def _filterItemsWithPublisher(self, cursor, itemIdentifiers, requestor):
+        self._checkNodeExists(cursor)
+        ret = []
+        for itemIdentifier in itemIdentifiers:
+            args = ["%s/%%" % requestor.userhost(), itemIdentifier]
+            cursor.execute("""SELECT item FROM items WHERE publisher LIKE %s AND item=%s""", args)
+            result = cursor.fetchone()
+            if result:
+                ret.append(result[0])
+        return ret
+
 class CollectionNode(Node):
 
     nodeType = 'collection'