Mercurial > libervia-pubsub
comparison sat_pubsub/pgsql_storage.py @ 308:087b705493a6
fixed publisher check on item publishing
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 18 Dec 2015 13:01:02 +0100 |
parents | 05c875a13a62 |
children | 890b24b37b56 |
comparison
equal
deleted
inserted
replaced
307:c057d78b482f | 308:087b705493a6 |
---|---|
913 | 913 |
914 | 914 |
915 def getItemsPublishers(self, itemIdentifiers): | 915 def getItemsPublishers(self, itemIdentifiers): |
916 """Get the publishers for all given identifiers | 916 """Get the publishers for all given identifiers |
917 | 917 |
918 @return (dict): map of itemIdentifiers to publisher | 918 @return (dict[unicode, jid.JID]): map of itemIdentifiers to publisher |
919 if item is not found, key is skipped in resulting dict | |
919 """ | 920 """ |
920 return self.dbpool.runInteraction(self._getItemsPublishers, itemIdentifiers) | 921 return self.dbpool.runInteraction(self._getItemsPublishers, itemIdentifiers) |
921 | 922 |
922 | 923 |
923 def _getItemsPublishers(self, cursor, itemIdentifiers): | 924 def _getItemsPublishers(self, cursor, itemIdentifiers): |
926 for itemIdentifier in itemIdentifiers: | 927 for itemIdentifier in itemIdentifiers: |
927 cursor.execute("""SELECT publisher FROM items | 928 cursor.execute("""SELECT publisher FROM items |
928 WHERE item=%s""", | 929 WHERE item=%s""", |
929 (itemIdentifier,)) | 930 (itemIdentifier,)) |
930 result = cursor.fetchone() | 931 result = cursor.fetchone() |
931 if not result: | 932 if result: |
932 # We have an internal error, that's why we use ValueError | 933 ret[itemIdentifier] = jid.JID(result[0]) |
933 # and not error.ItemNotFound() | |
934 raise ValueError() # itemIdentifier must exists | |
935 ret[itemIdentifier] = jid.JID(result[0]) | |
936 return ret | 934 return ret |
937 | 935 |
938 | 936 |
939 def purge(self): | 937 def purge(self): |
940 return self.dbpool.runInteraction(self._purge) | 938 return self.dbpool.runInteraction(self._purge) |