Esempio n. 1
0
    def _addUser(self, user):
        def _added(result):
            user.setState("added")
            self.clean = False
            return result

        def _failed(fail):
            self.clean = False
            if fail.check(ftwitter.Canceled):
                # The state has been changed to canceled below.
                assert user.canceled()
                log.msg("Addition of user %r canceled." % user.screenname)
            else:
                user.setState("failed")
                log.msg("Failed to add %r: %s" % (user.screenname, fail))
                if hasattr(fail.value, "response_headers"):
                    for header in fail.value.response_headers:
                        if header.startswith("x-fluiddb-"):
                            print "\t%s: %s" % (header, fail.value.response_headers[header][0])

        log.msg("User %r received from request queue." % user.screenname)
        user.setState("underway")
        d = ftwitter.addUserByScreenname(self.cache, self.endpoint, user)
        d.addCallbacks(_added, _failed)
        d.addErrback(log.err)
        return d
Esempio n. 2
0
    def _addUser(self, user):
        def _added(result):
            user.setState("added")
            self.clean = False
            return result

        def _failed(fail):
            self.clean = False
            if fail.check(ftwitter.Canceled):
                # The state has been changed to canceled below.
                assert user.canceled()
                log.msg("Addition of user %r canceled." % user.screenname)
            else:
                user.setState("failed")
                log.msg("Failed to add %r: %s" % (user.screenname, fail))

        log.msg("User %r received from request queue." % user.screenname)
        user.setState("underway")
        d = ftwitter.addUserByScreenname(self.cache, self.endpoint, user)
        d.addCallbacks(_added, _failed)
        d.addErrback(log.err)
        return d