Beispiel #1
0
 def callObject(self, request, ob):
     # Exception handling, dont try to call request.method
     orig = ob
     if not IHTTPException.providedBy(ob):
         ob = zapi.queryMultiAdapter((ob, request), name=request.method)
         ob = getattr(ob, request.method, None)
         if ob is None:
             raise MethodNotAllowed(orig, request)
     return mapply(ob, request.getPositionalArguments(), request)
Beispiel #2
0
 def callObject(self, request, ob):
     # Exception handling, dont try to call request.method
     orig = ob
     if not IHTTPException.providedBy(ob):
         ob = zope.component.queryMultiAdapter((ob, request),
                                               name=request.method)
         ob = getattr(ob, request.method, None)
         if ob is None:
             raise MethodNotAllowed(orig, request)
     return mapply(ob, request.getPositionalArguments(), request)
Beispiel #3
0
    def testbasicauth(self):
        from zope.app.http.exception.unauthorized import Unauthorized
        exception = Exception()
        try:
            raise exception
        except:
            pass
        request = TestRequest()
        u = Unauthorized(exception, request)

        # Chech that we implement the right interface
        self.failUnless(IHTTPException.providedBy(u))
        
        # Call the view
        u()
        
        # Make sure the response status was set
        self.assertEqual(request.response.getStatus(), 401)
        self.failUnless(request.response.getHeader('WWW-Authenticate', '', True).startswith('basic'))
Beispiel #4
0
    def testbasicauth(self):
        from zope.app.http.exception.unauthorized import Unauthorized
        exception = Exception()
        try:
            raise exception
        except:
            pass
        request = TestRequest()
        u = Unauthorized(exception, request)

        # Chech that we implement the right interface
        self.failUnless(IHTTPException.providedBy(u))

        # Call the view
        u()

        # Make sure the response status was set
        self.assertEqual(request.response.getStatus(), 401)
        self.failUnless(
            request.response.getHeader('WWW-Authenticate', '',
                                       True).startswith('basic'))