예제 #1
0
    def _on_async_req_to_key_store_done(self, is_ok, code=None, body=None):
        """Called when async_req_to_key_store() completes."""

        if not is_ok or code != httplib.CREATED:
            self._callback(None)
            return

        creds = filter_out_non_model_creds_properties(self._creds)
        self._callback(creds)
예제 #2
0
    def _on_async_req_to_key_store_done(self, is_ok, code=None, body=None):
        """Called when async_req_to_key_store() is done."""

        if not is_ok or httplib.OK != code or body is None:
            self._callback(None, None)
            return

        creds = []
        for row in body.get("rows", []):
            doc = row.get("value", {})
            if self._is_filter_out_non_model_properties:
                doc = filter_out_non_model_creds_properties(doc)
            creds.append(doc)

        if self._key:
            # asked to retrive a single set of creds so
            # expecting 1 or 0 values in "creds"
            num_creds = len(creds)

            if 0 == num_creds:
                self._callback(None, False)
            else:
                if 1 == num_creds:
                    self._callback(creds[0], False)
                else:
                    # this is an error case with either the view or the
                    # data in the key store - we should never here.
                    fmt = (
                        "Got %d docs from Key Store for key '%s'. "
                        "Expected 1 or 0 docs."
                    )
                    _logger.error(fmt, num_creds, self._key)

                    self._callback(None, None)
        else:
            self._callback(creds, True)