Пример #1
0
    def _request(request_handler, *args):
        """Surround request_handler.method(*args) with try/except for errors.

    Args:
      request_handler: Request handler which method is being called.
    """
        try:
            method(request_handler, *args)
        except Error, error:
            response_body = {
                'error': {
                    'status': error.code,
                    'message': error.message
                }
            }
            request_handler.response.clear()
            request_handler.response.set_status(error.code)
            util.write_response(request_handler, response_body)
  def _request(request_handler, *args):
    """Surround request_handler.method(*args) with try/except for errors.

    Args:
      request_handler: Request handler which method is being called.
    """
    try:
      method(request_handler, *args)
    except Error, error:
      response_body = {
          'error': {
              'status': error.code,
              'message': error.message
          }
      }
      request_handler.response.clear()
      request_handler.response.set_status(error.code)
      util.write_response(request_handler, response_body)
Пример #3
0
 def do_cmd(self, cmd, **other):
     d = { 'cmd': cmd }
     d.update(other)
     write_response(self.sock, d)
     return read_response(self.sock)
Пример #4
0
 def post(self):
   """Handle code exchange."""
   self._process_request_body()
   self._exchange_code()
   user = self._create_user()
   util.write_response(self, user.to_dict())
Пример #5
0
 def reply(self, json):
     logger.debug('%r: Sending reply: %r', self.addr, json)
     util.write_response(self.sock, json)
 def put(self):
     """Update settings for the provided user."""
     self._get_user()
     self._process_request_body()
     util.write_response(self, self._user.to_dict())
 def get(self):
     """Retrieve settings for the provided user."""
     self._get_user()
     util.write_response(self, self._user.to_dict())
Пример #8
0
 def put(self):
   """Update settings for the provided user."""
   self._get_user()
   self._process_request_body()
   util.write_response(self, self._user.to_dict())
Пример #9
0
 def get(self):
   """Retrieve settings for the provided user."""
   self._get_user()
   util.write_response(self, self._user.to_dict())