Introduction
pyramid_heroku is a collection of tweens and helpers to successfully run Pyramid on Heroku
It provides the following:
ClientAddr tween that sets real user’s IP to request.client_addr
Host tween that sets request.host to proxied X-Forwarded-Host header (note: potential security risk)
HerokuappAccess tween that denies access to your app’s <app>.herokuapp.com domain for any non-whitelisted IPs.
migrate.py script for automatically running alembic migrations on deploy.
maintenance.py script for controlling Heroku maintenance mode.
Installation
Just do
pip install pyramid_heroku
or
easy_install pyramid_heroku
Compatibility
pyramid_heroku runs with pyramid>=1.7 and python>=3.6. Other versions might also work.
Documentation
Usage example for tweens:
def main(global_config, **settings):$ cat .heroku/release.sh
config = Configurator(settings=settings)
config.include('pyramid_heroku.client_addr')
config.include('pyramid_heroku.herokuapp_access')
return config.make_wsgi_app()
The pyramid_heroku.herokuapp_access tween depends on pyramid_heroku.client_addr tween and it requires you to list whitelisted IPs in the pyramid_heroku.herokuapp_whitelist setting.
Usage example for automatic alembic migration script:
$ cat .heroku/release.sh #!/usr/bin/env bash set -e echo "Running migrations" python -m pyramid_heroku.migrate my_app etc/production.ini echo "DONE!"
For migration script to work, you need to set the MIGRATE_API_SECRET_HEROKU env var in Heroku. This allows the migration script to use the Heroku API.
Before running DB migration, the script will enable Heroku maintenance mode if the app is not already in maintenance mode. After the migration, maintenance mode will be disabled only if it was enabled by the migration script.
Maintenance mode can also be enabled/disabled using the pyramid_heroku.maintenance script.
Usage example for enabling the Heroku maintenance mode:
python -m pyramid_heroku.maintenance on my_app etc/production.ini
If you use structlog, add the following configuration setting to your INI file to enable structlog-like logging:
pyramid_heroku.structlog = true
See tests for more examples.
Releasing
Update CHANGES.rst.
Update pyproject.toml version.
Run poetry check.
Run poetry publish --build.
We’re hiring!
At Niteo we regularly contribute back to the Open Source community. If you do too, we’d like to invite you to join our team!
Metadata
Release files for pyramid_heroku 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyramid_heroku-0.8.0.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyramid_heroku-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.5 kB
Release files / pyramid_heroku-0.8.0.tar.gz
| Download URL | pyramid_heroku-0.8.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf92d7bec504cd8ce64d87545b566595ec5d89467cade34abbbb1afdf82e7b87
|
|
BLAKE2b-256 checksum How to use checksums |
57861a71dd77abaa3d50acddb6ee3170f50f4b6ba1214d7b098c0c94959f1e4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.6 Linux/5.9.16-1-MANJARO
|
Release files / pyramid_heroku-0.8.0-py3-none-any.whl
| Download URL | pyramid_heroku-0.8.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a614c4666148f45f4c34ea1f9de561c76f5996275988b4821531f00a955df455
|
|
BLAKE2b-256 checksum How to use checksums |
c102bdf4d249f860abb5de553256545817cb98b32ecdf1c9ab4f0f736cfe3bd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.6 Linux/5.9.16-1-MANJARO
|