Metadata-Version: 2.1
Name: pyramid-heroku
Version: 0.7.0
Summary: A bunch of helpers for successfully running Pyramid on Heroku.
Home-page: https://github.com/niteoweb/pyramid_heroku
License: BSD-3-Clause
Keywords: pyramid,heroku,pylons,web
Author: Niteo
Author-email: info@niteo.co
Requires-Python: >=3.6
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pylons
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: expandvars
Requires-Dist: pyramid (>=1.7)
Requires-Dist: requests
Description-Content-Type: text/x-rst

pyramid_heroku
==============

Introduction
------------

pyramid_heroku is a collection of tweens and helpers to successfully run `Pyramid <http://www.trypyramid.com/>`_ on `Heroku <https://heroku.com/>`_

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
---------

#. Update CHANGES.rst.
#. Update pyproject.toml version.
#. Run ``poetry check``.
#. Run ``poetry publish``.


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
<https://niteo.co/careers/>`_!

