Skip to main content

A bunch of helpers for successfully running Pyramid on Heroku.

Project description

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.

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.

See tests for more examples.

If you use structlog, add the following configuration setting to your INI file to enable structlog-like logging:

pyramid_heroku.structlog = true

Releasing

  1. Update CHANGES.rst.

  2. Update pyproject.toml version.

  3. Run poetry check.

  4. 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!

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

pyramid_heroku-0.7.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

pyramid_heroku-0.7.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file pyramid_heroku-0.7.0.tar.gz.

File metadata

  • Download URL: pyramid_heroku-0.7.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Darwin/19.6.0

File hashes

Hashes for pyramid_heroku-0.7.0.tar.gz
Algorithm Hash digest
SHA256 6ca1e11bfadbe4276d6e5c32dd2ef7b0f96883f9a658059209ef3dc822ca0e30
MD5 535427caebfb1fbdc3977c795cf11207
BLAKE2b-256 19353acb7d1f834214025156495d32bc1b26146a83b272c37d412209ae181f5f

See more details on using hashes here.

File details

Details for the file pyramid_heroku-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: pyramid_heroku-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Darwin/19.6.0

File hashes

Hashes for pyramid_heroku-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a9bd6439d46584860c7ea269074eb71c8c1b60d6e4b9a14b81bcaf1c8570e7d
MD5 28b865ed4179f244a3f164d0bc5c2e39
BLAKE2b-256 2b4b122bcaad71df64f7a3ce20441b4277389366a9e8a6a717d173f6bfe5be2e

See more details on using hashes here.

Supported by

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