Throwing web exceptions like in AioHTTP
Project description
Throwing web exceptions like in AioHTTP
What and why?
In AioHTTP you cat raise any response as exception (this is very cool). But Django can raise only 3+1 web exceptions.
403 PermissionDenied
404 Http404
500 Any other non catched exception
This package allow you to raise as exception any on HTTP response.
Quickstart
Install Django Web Exceptions:
pip install django-web-exceptions
Add it to your MIDDLEWARE:
MIDDLEWARE = (
# ...
'web_exceptions.middleware.WebExceptionsMiddleware',
# ...
)
Features
Import exceptions and raise anywhere
from web_exceptions import exceptions
# ...
def index(request):
""" Simple view raise redirectexception """
raise exceptions.HTTPMovedPermanently('/foo')
Also you cat customize any kind of exception status code as custom handler, defined in urls.py like django error handlers .
# urls.py
from myapp import views
handler300 = <callable view>
handler400 = <callable view>
handler<status_code> = <callable view>
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Credits
Tools used in rendering this package:
History
0.1.0 (2017-05-13)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-web-exceptions-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cabfbf117a76325fae12ebe9a12c811ef96de6a5a28242f019fbb193ef60a853 |
|
MD5 | 938862c44d5e9b08a8ec5cd141004b92 |
|
BLAKE2b-256 | e2493ea50aed80342a1d34d3c37256c78bc32d9bcef0d4bd7658c716334c15d1 |
Hashes for django_web_exceptions-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df6f236ac41449d1e4ec380b229d87d32d8bfd1d9dc60abb531d71c8a98a89df |
|
MD5 | f17eec0fd09e18f62f4a835604f1be49 |
|
BLAKE2b-256 | f7d986389639efc18a4b713f51b1d4056757efa773b2b91da28b0e4a05122145 |