Skip to main content

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

  • 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>=2.7 and python>=3.5. 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 app:main

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 setup.py version.

  3. Run bin/longtest.

  4. Run python setup.py sdist upload.

Changes

0.1.1

  • Fix tween paths. [zupo]

0.1

  • Initial release. [dz0ny, zupo]

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.1.1.tar.gz (6.1 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for pyramid_heroku-0.1.1.tar.gz
Algorithm Hash digest
SHA256 641eb0c7f1fa93a5301e93659cf1e2c9a6ff70d89036cceb315acb12a1244879
MD5 401fe7e7a10530b30686def1c556474e
BLAKE2b-256 a315ae1b085878318be340a0c5ddc1f2bc95cac8e448b8235543b4a03b0a19cb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11

2 files

0.10.6

2 files

0.10.5

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.10

2 files

0.9.2

2 files

0.9.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

1 file

0.5.0

2 files

0.4.0

1 file

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.2

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

This release

0.1.1 This release

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page