This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

SUMMARY

Flask_replicated is a Flask extension, designed to work with SqlAlchemy. It’s purpose it to provide more or less automatic master-slave replication. On each request, extension determines database usage intention (to read or to write into a database). Then, it picks right database url inside overriden db.get_engine() whenever request handler tries to access database.

INSTALLATION

  1. Install flask_replicated distribution using “python setup.py install”.

  2. In flask app.config configure your database bindings a standard way:

    SQLALCHEMY_DATABASE_URI = '%(schema)s://%(user)s:%(password)s@%(master_host)s/%(database)s'
    SQLALCHEMY_BINDS = {
        'master': SQLALCHEMY_DATABASE_URI,
        'slave': '%(schema)s://%(user)s:%(password)s@%(slave_host)s/%(database)s'
    }
    
  3. Register app extension:

    app = Flask(...)
    ...
    FlaskReplicated(app)
    

USAGE

Flask_replicated routes SQL queries into different databases based on request method. If method is one of READONLY_METHODS which are defined as set([‘GET’, ‘HEAD’])

While this is usually enough there are cases when DB access is not controlled explicitly by your business logic. Good examples are implicit creation of sessions on first access, writing some bookkeeping info, implicit registration of a user account somewhere inside the system. These things can happen at arbitrary moments of time, including during GET requests.

To handle these situations wrap appropriate view function with @flask_replicated.changes_database decorator. It will mark function to always use master database url.

GET after POST

There is a special case that needs addressing when working with asynchronous replication scheme. Replicas can lag behind a master database on receiving updates. In practice this mean that after submitting a POST form that redirects to a page with updated data this page may be requested from a slave replica that wasn’t updated yet. And the user will have an impression that the submit didn’t work.

Release History

Release History

1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
flask_replicated-1.1.tar.gz (2.6 kB) Copy SHA256 Checksum SHA256 Source Apr 27, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting