Exemplo n.º 1
0
    def trace(self, data, check, mutator):
        """Handler for HTTP TRACE request.

    Args:
      data: A soc.views.helper.request_data.RequestData.
      check: A soc.views.helper.access_checker.AccessChecker.
      mutator: A soc.views.helper.access_checker.Mutator.

    Returns:
      An http.HttpResponse appropriate for the given request parameters.

    Raises:
      exception.LoginRequired: An exception.LoginRequired indicating
        that the user is not logged in, but must log in to access the
        resource specified in their request.
      exception.Redirect: An exception.Redirect indicating that the
        user is to be redirected to another URL.
      exception.UserError: An exception.UserError describing what was
        erroneous about the user's request and describing an appropriate
        response.
      exception.ServerError: An exception.ServerError describing some
        problem that arose during request processing and describing an
        appropriate response.
    """
        raise exception.MethodNotAllowed()
Exemplo n.º 2
0
    def _dispatch(self, data, check, mutator):
        """Dispatches the HTTP request to its respective handler method.

    Args:
      data: The request_data.RequestData object for the current request.
      check: The access_checker.AccessChecker object for the current
        request.
      mutator: The access_checker.Mutator object for the current
        request.

    Returns:
      An http.HttpResponse appropriate for the current request.

    Raises:
      exception.LoginRequired: An exception.LoginRequired indicating
        that the user is not logged in, but must log in to access the
        resource specified in their request.
      exception.Redirect: An exception.Redirect indicating that the
        user is to be redirected to another URL.
      exception.UserError: An exception.UserError describing what was
        erroneous about the user's request and describing an appropriate
        response.
      exception.ServerError: An exception.ServerError describing some
        problem that arose during request processing and describing an
        appropriate response.
    """
        if data.request.method == 'GET':
            if data.request.GET.get('fmt') == 'json':
                return self.json(data, check, mutator)
            else:
                return self.get(data, check, mutator)
        elif data.request.method == 'POST':
            if db.WRITE_CAPABILITY.is_enabled():
                return self.post(data, check, mutator)
            else:
                referrer = data.request.META.get('HTTP_REFERER', '')
                params = urllib.urlencode({'dsw_disabled': 1})
                return http.HttpResponseRedirect('%s?%s' % (referrer, params))
        elif data.request.method == 'HEAD':
            return self.head(data, check, mutator)
        elif data.request.method == 'OPTIONS':
            return self.options(data, check, mutator)
        elif data.request.method == 'PUT':
            return self.put(data, check, mutator)
        elif data.request.method == 'DELETE':
            return self.delete(data, check, mutator)
        elif data.request.method == 'TRACE':
            return self.trace(data, check, mutator)
        else:
            raise exception.MethodNotAllowed()
Exemplo n.º 3
0
    def post(self, data, check, mutator):
        """Handles student form verification by host."""
        if not data.url_profile.student_info:
            # TODO(nathaniel): Is this user error? If so, should it be
            # logged at server warning level, or even at all?
            logging.warn(NON_STUDENT_ERR_MSG)
            raise exception.MethodNotAllowed()

        post_data = data.POST
        button_id = post_data.get('id')
        value = post_data.get('value')

        if button_id == 'verify-consent-form':
            self._verifyConsentForm(data, value)
        elif button_id == 'verify-student-id-form':
            self._verifyStudentIDForm(data, value)

        return http.HttpResponse()
Exemplo n.º 4
0
 def get(self, data, check, mutator):
     """Special Handler for HTTP GET since this view only handles POST."""
     raise exception.MethodNotAllowed()
Exemplo n.º 5
0
 def get(self, data, check, mutator):
     """This view only handles POST."""
     raise exception.MethodNotAllowed()