Git Product home page Git Product logo

flask-continuum's Introduction

Uncomment below for banners

Build status Code coverage Maintenance yes GitHub license Documentation Status

Flask-Continuum

Flask-Continuum is a lightweight Flask extension for providing data provenance and versioning support to Flask applications using SQLAlchemy. It is built on top of the sqlalchemy-continuum package, and provides a more Flask-y development experience for app configuration. If you'd like to configure your application with sqlalchemy-continuum directly, consult the sqlalchemy-continuum documentation.

Installation

To install the latest stable release via pip, run:

$ pip install Flask-Continuum

Alternatively with easy_install, run:

$ easy_install Flask-Continuum

To install the bleeding-edge version of the project (not recommended):

$ git clone http://github.com/bprinty/Flask-Continuum.git
$ cd Flask-Continuum
$ python setup.py install

Usage

Setting up the flask application with extensions:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_continuum import Continuum

app = Flask(__name__)
db = SQLAlchemy(app)
continuum = Continuum(app, db)

Or, using via the Flask app factory pattern:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_continuum import Continuum

db = SQLAlchemy()
continuum = Continuum(db=db)
app = Flask(__name__)
db.init_app(app)
continuum.init_app(app)

The following is a minimal example highlighting how the extension is used. Much of the example was taken from the SQLAlchemy-Continuum documentation to show how this plugin extends that package for a Flask application:

from flask_continuum import VersioningMixin

# defining database schema
class Article(db.Model, VersioningMixin):
    __tablename__ = 'article'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.Unicode(255))
    content = db.Column(db.UnicodeText)


# later in api or request handlers
article = Article(name='Some article', content='Some content')
session.add(article)
session.commit()

# article has now one version stored in database
article.versions[0].name
# 'Some article'

article.name = 'Updated name'
session.commit()

article.versions[1].name
# 'Updated name'


# lets revert back to first version
article.versions[0].revert()

article.name
# 'Some article'

Documentation

For more detailed documentation, see the Docs.

Questions/Feedback

File an issue in the GitHub issue tracker.

flask-continuum's People

Contributors

bprinty avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.