def respondWithPost(self, PostFingerprint): d = Mercury.getPost(PostFingerprint) d.addCallback(Mercury.toJson) def processAndReturn(postAsJson): reply = {'Post': postAsJson} return reply d.addCallback(processAndReturn)\ .addErrback(self.closeConnection, 'INBOUND', self.respondWithPost.__name__) return d
def respondWithPost(self, PostFingerprint): d = Mercury.getPost(PostFingerprint) d.addCallback(Mercury.toJson) def processAndReturn(postAsJson): reply = { 'Post': postAsJson } return reply d.addCallback(processAndReturn)\ .addErrback(self.closeConnection, 'INBOUND', self.respondWithPost.__name__) return d
def respondWithPost(self, PostFingerprint): if not self.connectedNode: self.abortConnection(Exception("AetherError: Illegal request from remote."), "L<-R", "respondWithPost") print("L->R: Post reply. Post: ", PostFingerprint, " N:", self.connectedNode["NodeId"]) d = Mercury.getPost(PostFingerprint) d.addCallback(Mercury.toJson) def processAndReturn(postAsJson): reply = {"Post": postAsJson} return reply d.addCallback(processAndReturn).addErrback(self.abortConnection, "L<-R", self.respondWithPost.__name__) return d
def respondWithPost(self, PostFingerprint): if not self.connectedNode: self.abortConnection(Exception('AetherError: Illegal request from remote.'), 'L<-R', 'respondWithPost') print('L->R: Post reply. Post: ', PostFingerprint, ' N:', self.connectedNode['NodeId']) d = Mercury.getPost(PostFingerprint) d.addCallback(Mercury.toJson) def processAndReturn(postAsJson): reply = { 'Post': postAsJson } return reply d.addCallback(processAndReturn)\ .addErrback(self.abortConnection, 'L<-R', self.respondWithPost.__name__) return d
def respondWithPost(self, PostFingerprint): if not self.connectedNode: self.abortConnection( Exception('AetherError: Illegal request from remote.'), 'L<-R', 'respondWithPost') print('L->R: Post reply. Post: ', PostFingerprint, ' N:', self.connectedNode['NodeId']) d = Mercury.getPost(PostFingerprint) d.addCallback(Mercury.toJson) def processAndReturn(postAsJson): reply = {'Post': postAsJson} return reply d.addCallback(processAndReturn)\ .addErrback(self.abortConnection, 'L<-R', self.respondWithPost.__name__) return d