예제 #1
0
    def _getNode(self, cursor, nodeIdentifier):
        configuration = {}
        cursor.execute(
            """SELECT node_type,
                                 persist_items,
                                 deliver_payloads,
                                 send_last_published_item
                          FROM nodes
                          WHERE node=%s""", (nodeIdentifier, ))
        row = cursor.fetchone()

        if not row:
            raise error.NodeNotFound()

        if row.node_type == 'leaf':
            configuration = {
                'pubsub#persist_items': row.persist_items,
                'pubsub#deliver_payloads': row.deliver_payloads,
                'pubsub#send_last_published_item': row.send_last_published_item
            }
            node = LeafNode(nodeIdentifier, configuration)
            node.dbpool = self.dbpool
            return node
        elif row.node_type == 'collection':
            configuration = {
                'pubsub#deliver_payloads': row.deliver_payloads,
                'pubsub#send_last_published_item': row.send_last_published_item
            }
            node = CollectionNode(nodeIdentifier, configuration)
            node.dbpool = self.dbpool
            return node
예제 #2
0
    def trapNotFound(self, failure):
        failure.trap(StanzaError)

        if failure.value.condition == 'item-not-found':
            raise error.NodeNotFound()
        else:
            return failure
예제 #3
0
    def deleteNode(self, nodeIdentifier):
        try:
            del self._nodes[nodeIdentifier]
        except KeyError:
            return defer.fail(error.NodeNotFound())

        return defer.succeed(None)
예제 #4
0
    def getNode(self, nodeIdentifier):
        try:
            node = self._nodes[nodeIdentifier]
        except KeyError:
            return defer.fail(error.NodeNotFound())

        return defer.succeed(node)
예제 #5
0
 def deleteNode(self, nodeIdentifier):
     if nodeIdentifier in ['to-be-deleted']:
         self.deleteCalled.append(nodeIdentifier)
         return defer.succeed(None)
     else:
         return defer.fail(error.NodeNotFound())
예제 #6
0
 def _checkNodeExists(self, cursor):
     cursor.execute("""SELECT node_id FROM nodes WHERE node=%s""",
                    (self.nodeIdentifier, ))
     if not cursor.fetchone():
         raise error.NodeNotFound()
예제 #7
0
    def _deleteNode(self, cursor, nodeIdentifier):
        cursor.execute("""DELETE FROM nodes WHERE node=%s""",
                       (nodeIdentifier, ))

        if cursor.rowcount != 1:
            raise error.NodeNotFound()