Skip to main content

Manages automatic updates and evolutions which are better suited outside schema migrations

Project description

tgext.evolve is a TurboGears2 extension for generic migrations and evolutions.

tgext.evolve is safe to be used in multiprocessing and multithreading environments as it relies on a distributed lock on your database to perform evolutions.

During the evolution period the application will respond with a 503 status code, feel free to configure TurboGears to trap it and use your ErrorController to provide a custom page.

Installing

tgext.evolve can be installed from pypi:

pip install tgext.evolve

should just work for most of the users.

Enabling

To enable tgext.evolve put inside your application config/app_cfg.py the following:

import tgext.evolve
tgext.evolve.plugme(base_config, options={
    'evolutions': [
        # ... Your evolutions ...
    ]
})

or you can use tgext.pluggable when available:

from tgext.pluggable import plug
plug(base_config, 'tgext.evolve', evolutions=[
    # ... Your evolutions ...
])

Using Evolutions

Evolutions are a subclass of tgext.evolve.Evolution that must provide an evolution_id property and an evolve() method.

Here is a sample evolution that does not much apart waiting for 10 seconds:

import time
from tgext.evolve import Evolution

class TestEvolution1(Evolution):
    evolution_id = 'test_evolution_1'

    def evolve(self):
        time.sleep(10)

Please note that in case you modify data or touch the database through model.DBSession or other manners you must flush and commit your UnitOfWork and Transaction yourself as evolutions are performed outside the transaction manager in a separated thread.

Then you can register your evolution with something like:

from tgext.pluggable import plug
plug(base_config, 'tgext.evolve', evolutions=[
    TestEvolution1
])

In case your evolution requires parameters you can register an instance of it instead of registering the class.

ChangeLog

0.0.1

  • First release with only MongoDB/Ming support.

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

tgext.evolve-0.0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file tgext.evolve-0.0.1.tar.gz.

File metadata

File hashes

Hashes for tgext.evolve-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6e6f40d1dba0a150e4a1ea46dc46fcd6ea2ec087c893bdee1bc9f6fc7066c796
MD5 f4caa446f95ef2311e7470fa198658a5
BLAKE2b-256 a1be5fe985f447dc45149d334b027d41e75ac3906dffe5b325a5e8ba83a4b872

See more details on using hashes here.

Supported by

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