Skip to main content

Allows view code to exit early and return a given HttpResponse by raising an exception

Project description

django_early_return

Installation

  • pip install django_early_return
  • add 'django_early_return.EarlyReturnMiddleware' to MIDDLEWARE in your settings
  • optionally, add 'django_early_return' to INSTALLED_APPS, if you want to run our tests when executing python manage.py test

Usage

Any view code (or middleware code, if that middleware is installed after EarlyReturnMiddleware) can now instantiate EarlyReturn with any HttpResponse, and that response will be returned to the user:

    if not request.user.has_perm('my_app.some_permission'):
        raise django_early_return.EarlyReturn(http.HttpResponseForbidden())

For code in helper functions/middleware/etc., this is often more convenient than passing a response back to the actual view code.

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

django_early_return-0.0.1.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

django_early_return-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file django_early_return-0.0.1.tar.gz.

File metadata

  • Download URL: django_early_return-0.0.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for django_early_return-0.0.1.tar.gz
Algorithm Hash digest
SHA256 91144d29d0fa8aad78aae2b6ad5066759e3cf99b168834b6114423650eee0657
MD5 44784dd00935b9ccbc5be22d352fffcd
BLAKE2b-256 9dad14dba4e6d0c2dbc0ad7199aa27ad7ce04e1cb95d4a2a5f479936e1d447ef

See more details on using hashes here.

File details

Details for the file django_early_return-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_early_return-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for django_early_return-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a5726670aa0f6f4ca2c0664aabe6022f0c11602f92912d0c7ebee95cefe1339
MD5 df4a55f88a8a44d8e33a7c997ebd2ea8
BLAKE2b-256 732b0dcbf3ffa98ffa25ea7e597b0328a98783f49e38b84ded8eccafa4357b99

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page