Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A CRUD manager for Flask

Project Description

A CRUD like manager for Flask.

Is Flexible

Save in a hello.py:

from flask import Flask
from flask_manager import crud, controller, rules as rules_

all_items = {
    i: {'id': i, 'title': 'Title - {}'.format(i)}
    for i in range(100)
}
next_id = 100

class Controller(controller.Controller):
    def get_items(self, page=1, order_by=None, filters=None):
        return all_items, len(all_items)

    def get_item(self, pk):
        return all_items[pk]

    def create_item(self, form):
        # wtforms does not support dicts :( (I think:P)
        global next_id
        all_items[next_id] = {
            'id': next_id, 'title': 'Title - {}'.format(next_id)}
        next_id += 1

    def update_item(self, item, form):
        # wtforms does not support dicts :( (I think:P)
        pass

    def delete_item(self, pk):
        del all_items[pk]


class Crud(crud.Crud):
    controller = Controller()
    # you may merge read/update to "form" if using the same columns
    rules = {
        'list': rules.ColumnSet(['title']),
        'create': rules.FormFieldSet(['title']),
        'read': rules.DataFieldSet(['title']),
        'update': rules.FormFieldSet(['title']),
        'delete': rules.DataFieldSetWithConfirm(['title']),
    }

if __name__ == '__main__':
    app = Flask(__name__)
    admin = crud.Index('My Admin', url='', items=[
        Crud('My Crud'),
    ])
    app.register_blueprint(admin.create_blueprint())

Then execute:

$ pip install flask-manager
$ python hello.py
Release History

Release History

This version
History Node

0.0.1

History Node

0.0.1a0

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