• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 32. Exception Views > Step 2: Providing an Exception View

Step 2: Providing an Exception View

Now that you have a payment exception, you just have to provide a view for it. However, when the exception occurs, you do not want to return the HTTP status code 200. Instead, you want the status to be 402, which is the Payment Required status. In a new module named browser.py, you need to add the following view class:

01 class PaymentExceptionView(object):
02     """This is a view for `IPaymentException` exceptions."""
03
04     def __call__(self, *args, **kw):
05         self.request.response.setStatus(402)
06         return self.index(*args, **kw)


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint