Flask-Diamond is a batteries-included Flask framework.

Overview

Flask-Diamond

Flask-Diamond is a batteries-included Python Flask framework, sortof like Django but radically decomposable. Flask-Diamond offers some opinions about network information systems that process data. Using Flask-Diamond, you can scaffold a working application with sensible defaults, then easily override those defaults to meet your own goals. Flask-Diamond provides a shared vocabulary that helps teams coordinate as they scale up to develop multiple Flask applications while maintaining good code reuse and learning transfer. Flask-Diamond goes beyond a "project scaffold" by providing a complete architecture and team solution, including documentation, tutorials, and other learning support.

Overview

A Flask-Diamond application consists of facets, which are common facilities that many applications eventually need to provide. The facets provided by Flask-Diamond include:

  • account management
  • administrative access
  • databases
  • Model object CRUD
  • email
  • testing
  • documentation
  • deployment
  • and more

Usage

The following steps will create a new Flask-Diamond application.

pip install Flask-Diamond
mkdir my-application
cd my-application
flask-diamond scaffold app
make install docs test db server

Please read the Introduction Documentation to get started.

Documentation

http://flask-diamond.org

Quick Start Screencast

Flask-Diamond Quick Start

Length: 3:17

Comments
  • Tutorial crashes on user create

    Tutorial crashes on user create

    When I click "Create" on the user page, the app crashes. This happens on both localhost and PythonAnywhere.com

    Python version 2.7 (I used Python 3.5 on PythonAnywhere, same issue)

    Operating system Ubuntu 16.04.1 LTS

    The error message in the browser UndefinedError: 'flask_admin.contrib.sqla.form.UserForm object' has no attribute 'name'

    The error message that is logged on the command line UndefinedError: 'flask_admin.contrib.sqla.form.UserForm object' has no attribute 'name'

    opened by marcuskelly 3
  • Read the Docs, System requirements, Ubuntu, no package sqlite-dev

    Read the Docs, System requirements, Ubuntu, no package sqlite-dev

    I spent a bit of time trying to figure out how the Read the Docs are generated so that I could make a PR. The system requirements for Ubuntu list a package that does not exist. sqlite-dev does not exist. I used this command to search for possible packages. apt-cache search sqlite

    This might be the correct package sudo apt install libsqlite3-dev

    opened by stoneyv 2
  • Python 3: Generated secret key SyntaxError

    Python 3: Generated secret key SyntaxError

    Taking the quickstart for a spin with Python 3 and hitting this issue -- possibly related to #15.

    $ pip install Flask-Diamond
    $ mkdir my-app
    $ cd my-app
    $ flask-diamond scaffold app
    $ make install docs
    ..
    $ make test
    
    SETTINGS=$PWD/etc/conf/testing.conf $(which nosetests) my_app -c etc/nose/test.cfg
    ..
    Traceback (most recent call last):
      File "/path/to/venv/lib/python3.6/site-packages/nose/case.py", line 134, in run
        self.runTest(result)
      File "/path/to/venv/lib/python3.6/site-packages/nose/case.py", line 152, in runTest
        test(result)
      File "/path/to/venv/lib/python3.6/site-packages/flask_testing/utils.py", line 91, in __call__
        self._pre_setup()
      File "/path/to/venv/lib/python3.6/site-packages/flask_testing/utils.py", line 97, in _pre_setup
        self.app = self.create_app()
      File "/path/to/my_app/tests/mixins.py", line 15, in create_app
        app = create_app()
      File "/path/to/my_app/__init__.py", line 54, in create_app
        application.facet("configuration")
      File "/path/to/venv/lib/python3.6/site-packages/flask_diamond/__init__.py", line 61, in facet
        result = method_to_call(self, *args, **kwargs)
      File "/path/to/venv/lib/python3.6/site-packages/flask_diamond/facets/configuration.py", line 14, in init_configuration
        self.app.config.from_envvar('SETTINGS')
      File "/path/to/venv/lib/python3.6/site-packages/flask/config.py", line 109, in from_envvar
        return self.from_pyfile(rv, silent=silent)
      File "/path/to/venv/lib/python3.6/site-packages/flask/config.py", line 130, in from_pyfile
        exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
      File "/path/to/etc/conf/testing.conf", line 8
        SECRET_KEY = ""H\xf9\xc7\xb9\xe6\xcb\xd3\xd7?\x19\xde\xd3Ry\xe9wI6\xcc'q2\xc3N"
                       ^
    SyntaxError: invalid syntax
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/path/to/venv/bin/nosetests", line 11, in <module>
        load_entry_point('nose==1.3.4', 'console_scripts', 'nosetests')()
      File "/path/to/venv/lib/python3.6/site-packages/nose/core.py", line 121, in __init__
        **extra_args)
      File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/main.py", line 95, in __init__
        self.runTests()
      File "/path/to/venv/lib/python3.6/site-packages/nose/core.py", line 207, in runTests
        result = self.testRunner.run(self.test)
      File "/path/to/venv/lib/python3.6/site-packages/nose/core.py", line 62, in run
        test(result)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 178, in __call__
        return self.run(*arg, **kw)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 225, in run
        test(orig)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 178, in __call__
        return self.run(*arg, **kw)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 225, in run
        test(orig)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 178, in __call__
        return self.run(*arg, **kw)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 225, in run
        test(orig)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 178, in __call__
        return self.run(*arg, **kw)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 225, in run
        test(orig)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 178, in __call__
        return self.run(*arg, **kw)
      File "/path/to/venv/lib/python3.6/site-packages/nose/suite.py", line 225, in run
        test(orig)
      File "/path/to/venv/lib/python3.6/site-packages/nose/case.py", line 46, in __call__
        return self.run(*arg, **kwarg)
      File "/path/to/venv/lib/python3.6/site-packages/nose/case.py", line 139, in run
        result.addError(self, err)
      File "/path/to/venv/lib/python3.6/site-packages/nose/proxy.py", line 132, in addError
        self.result.addError(self.test, self._prepareErr(err))
      File "/path/to/venv/lib/python3.6/site-packages/nose/result.py", line 61, in addError
        exc_info = self._exc_info_to_string(err, test)
      File "/path/to/venv/lib/python3.6/site-packages/nose/result.py", line 187, in _exc_info_to_string
        return _TextTestResult._exc_info_to_string(self, err, test)
      File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/result.py", line 186, in _exc_info_to_string
        exctype, value, tb, limit=length, capture_locals=self.tb_locals)
      File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/traceback.py", line 504, in __init__
        self.filename = exc_value.filename
    AttributeError: 'SyntaxError' object has no attribute 'filename'
    make: *** [test] Error 1
    
    $ make db
    
    SETTINGS=$PWD/etc/conf/dev.conf bin/manage.py init_db
    ..
    Traceback (most recent call last):
      File "bin/manage.py", line 16, in <module>
        app = create_app()
      File "./my_app/__init__.py", line 54, in create_app
        application.facet("configuration")
      File "/path/to/venv/lib/python3.6/site-packages/flask_diamond/__init__.py", line 61, in facet
        result = method_to_call(self, *args, **kwargs)
      File "/path/to/venv/lib/python3.6/site-packages/flask_diamond/facets/configuration.py", line 14, in init_configuration
        self.app.config.from_envvar('SETTINGS')
      File "/path/to/venv/lib/python3.6/site-packages/flask/config.py", line 109, in from_envvar
        return self.from_pyfile(rv, silent=silent)
      File "/path/to/venv/lib/python3.6/site-packages/flask/config.py", line 130, in from_pyfile
        exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
      File "/path/to/etc/conf/dev.conf", line 8
        SECRET_KEY = ""H\xf9\xc7\xb9\xe6\xcb\xd3\xd7?\x19\xde\xd3Ry\xe9wI6\xcc'q2\xc3N"
                       ^
    SyntaxError: invalid syntax
    make: *** [db] Error 1
    

    From the generated etc/conf/dev.conf:

    SECRET_KEY = ""H\xf9\xc7\xb9\xe6\xcb\xd3\xd7?\x19\xde\xd3Ry\xe9wI6\xcc'q2\xc3N"
    

    The issue is in bin/flask-diamond:

        secret_str = repr(os.urandom(24).replace(b"\"", b"#").replace(b"%", b"#"))[1:-1]
    

    Looking at the repr result in Python 2, so the [1:-1] slice makes sense:

    >>> repr(os.urandom(24).replace(b"\"", b"#").replace(b"%", b"#"))
    "'\\xcc\\xc5\\x14\\xe6\\xfc7Q\\xf8\\x98\\x83\\xa3\\xf0sk\\xd5\\xfd\\xac\\xce\\\\\\x8f\\xf0\\xb4\\x93\\xd4'"
    

    Using the slice method Python 3 we see that it would need to be [2:-1]:

    >>> repr(os.urandom(24).replace(b"\"", b"#").replace(b"%", b"#"))
    'b"\\x89\\xd95\\xe3\\xc2\\x00\\xd2\\xfb>R\\x91\\xec\\xd2\'\\x87\\x94\\xd5\\x92F\\xfc@J\\xf1r"'
    

    But rather than setting up a conditional for the slice, maybe it would be better if we got away from byte conversion and did something like:

    import string
    import random
    
    chars = string.ascii_letters + string.digits + string.punctuation
    secret_str = ''.join([random.choice(chars) for x in range(24)])
    

    Fixed with on #26 to develop (w/ bump #25 ) or #27 to master

    opened by brennv 1
  • mr.bob has difficulty with randomly generated keys

    mr.bob has difficulty with randomly generated keys

    When generating random secrets, these sometimes contain escape characters that cause mr.bob quoting to be off-by-one.

    • One solution is to ensure proper escaping
    • another solution is to completely remove escape characters from keys
    • other solutions might exist too
    opened by iandennismiller 1
  • Relative file paths within modules are not dynamic by default

    Relative file paths within modules are not dynamic by default

    There is an issue whereby modules that depend on a non-module file within the project's directory hierarchy, doesn't respect the relative path to access it.

    My fix so far has been, inside of every module that loads a file, you dynamically declare the module path, and then os.path.join it with the filepath:

        MODULE_PATH = os.path.split(os.path.realpath(__file__))[0]
        ...
        f = open(os.path.join(MODULE_PATH, "my_directory/myfile.txt", "r")
    

    Maybe we can find or create a solution that works all the time without this boilerplate?

    opened by iandennismiller 1
  • References to Py2 dict.iteritems() must be updated to support Py3's dict.items()

    References to Py2 dict.iteritems() must be updated to support Py3's dict.items()

    I'm having issues calling models.CRUDMixin.update() because of this:

    https://github.com/diamond-org/flask-diamond/blob/develop/flask_diamond/mixins/crud.py#L90

    I've also confirmed and fixed this bug in Dodecahedron: updated update method and test code

    bug 
    opened by msarfati 0
  • Better support for

    Better support for "unicode" function in Python3

    Traceback (most recent call last): File "/home/msarfati/devel/pubgem/rss-aggregator/rss_aggregator/tests/models/test_rss_feed.py", line 25, in test_create rss_url="https://www.genericfeed.com/feed.xml", File "/home/msarfati/.virtualenvs/pubgem-rss-aggregator/lib/python3.5/site-packages/flask_diamond/mixins/crud.py", line 78, in create flask.current_app.logger.debug("create %s" % unicode(obj)) NameError: name 'unicode' is not defined You'll just have to update all the references to unicode throughout Diamond.

    bug 
    opened by msarfati 0
  • Update project for recent versions?

    Update project for recent versions?

    This library is quite dead as it uses a lot of old deprecated/removed features and throws a lot of errors on usage.

    Are there any plans to revive this? I would love to help bring it back to life, but my experience with python and flask is quite limited so I may not be the best person to restructure/update this old library.

    opened by Anachron 0
  • ValueError: too many values to unpack

    ValueError: too many values to unpack

    Getting this error when: following installation instructions, scaffolding a new flask-diamond application, logging in as [email protected]

    and trying to edit a user: ValueError: too many values to unpack

    opened by msteidley 3
  • Error when trying to create a new User (tutorial-planets)

    Error when trying to create a new User (tutorial-planets)

    Hi. This is my first try with Flask-Diamond. After setting up (following the tutorial) while testing, I get the following error message when accessing the page Admin -> User -> Create tab:

    jinja2.exceptions.UndefinedError UndefinedError: 'flask_admin.contrib.sqla.form.UserForm object' has no attribute 'name'.

    I've relatively new in python (1+year) and flask (almost the same period :) ). Any help will be greatly appreciated.

    I'm using: Python 2.7 my requirements.txt (for planets virtual-env) are as follow: alabaster==0.7.7 alembic==0.7.4 amqp==2.1.4 aniso8601==1.2.1 argh==0.26.2 asn1crypto==0.22.0 astroid==1.5.3 backports.functools-lru-cache==1.4 backports.shutil-get-terminal-size==1.0.0 bcrypt==3.1.3 billiard==3.5.0.2 blinker==1.4 celery==4.0.2 cffi==1.10.0 click==6.6 cryptography==1.9 decorator==4.0.11 docutils==0.13.1 enum34==1.1.6 Fabric3==1.13.1.post1 Flask==0.11.1 Flask-Admin==1.1.0 Flask-Assets==0.10 Flask-Celery-Helper==1.1.0 Flask-DbShell==1.0 Flask-DebugToolbar==0.9.2 Flask-Diamond==0.5.1 Flask-Login==0.3.2 Flask-Mail==0.9.1 Flask-Markdown==0.3 flask-marshmallow==0.5.0 Flask-Migrate==1.3.0 Flask-Principal==0.4.0 Flask-RESTful==0.3.2 Flask-Script==2.0.5 Flask-Security==1.7.5 Flask-SQLAlchemy==2.0 Flask-Testing==0.4.2 Flask-WTF==0.13.1 future==0.15.2 gitdb==0.6.4 GitPython==1.0.1 gunicorn==19.3.0 idna==2.5 ipaddress==1.0.18 ipython==5.4.1 ipython-genutils==0.2.0 itsdangerous==0.24 Jinja2==2.8 kombu==4.0.2 lazy-object-proxy==1.3.1 logilab-common==1.4.0 Mako==1.0.6 Markdown==2.6.8 MarkupSafe==1.0 marshmallow==1.2.6 mr.bob==0.1.1 nose==1.3.4 paramiko==2.2.1 passlib==1.7.1 pathlib2==2.3.0 pathtools==0.1.2 pexpect==4.2.1 pickleshare==0.7.4 prompt-toolkit==1.0.14 ptyprocess==0.5.2 pyasn1==0.2.3 pycparser==2.17 Pygments==2.2.0 pylint==1.4.1 PyNaCl==1.1.2 python-dateutil==2.6.0 pytz==2017.2 PyYAML==3.12 scandir==1.5 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.10.0 smmap==0.9.0 Sphinx==1.2.3 SQLAlchemy==1.1.11 traitlets==4.3.2 vine==1.1.3 watchdog==0.8.3 wcwidth==0.1.7 webassets==0.12.1 Werkzeug==0.11.11 wrapt==1.10.10 WTForms==1.0.5

    opened by ghost 3
  • Werkzeug 0.11.11 not compatible with windows + python 3.6

    Werkzeug 0.11.11 not compatible with windows + python 3.6

    It appears that python 3.6 eliminates socketserver.ForkingMixIn on platforms like windows which do not support the forking model. There is a fix for this in version 0.11.15. I am using werkzeug version 0.12.2 and it seems ok with python 3.6.1 on windows 10 pro.

    see: https://github.com/pallets/werkzeug/pull/999

    opened by cleemesser 3
  • using database from a library or script - how to?

    using database from a library or script - how to?

    Hello, I am new to flask, flask-sqlalchemy, and flask-diamond. My use case is that I would like to use flask-diamond to setup flask and sqlalchemy so that I can use my sqlalchemy database both as part of a web application and from my library and script codes outside of the web application.

    In the flask-alchemy documentation, it sounds like one needs to initialize sqlAlchemy's init_app and then create an application context (http://flask-sqlalchemy.pocoo.org/2.1/contexts/). It is not clear to me how much of this is already being done for me in flask-diamond. Can you clarify?

    Here is a template, assuming my flask-diamond application is myapplication. It appears to work, so I am guessing that I already have a context to work with.

    Can you clarify?

    Update

    I've traced back through the Diamond code and it looks like, I had things wrong before. To set up to access my flask-diamond database from an outside library or script, I need to do:

    # if flask-diamond has scaffolded out a new custom app called myapplication
    # SETTINGS needs to be already set either in the environment (or via os.environ['SETTINGS'])
    import myapplication
    app = myapplication.create_app()
    
    with app.app_context():
        do_stuff_with_app
    

    If others agree this is correct, I can write this up as documentation if there is a place for recipies or how to information.

    opened by cleemesser 0
  • why lock so many pkgs to OLD versions in requirements.txt?

    why lock so many pkgs to OLD versions in requirements.txt?

    For example:

    • flask-admin==1.1.0 (Current: 1.4.2)
    • wtforms==1.0.5 (Current: 2.1)

    I understand locking these in your own dev environments perhaps, but does your code REALLY not work with libraries as much as a full major version more recent?

    That seems like a flask-diamond problem that scares me.

    Thoughts?

    opened by xguse 4
flask-reactize is a boostrap to serve any React JS application via a Python back-end, using Flask as web framework.

flask-reactize Purpose Developing a ReactJS application requires to use nodejs as back end server. What if you want to consume external APIs: how are

Julien Chomarat 4 Jan 11, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 310 Dec 14, 2022
Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.

Flask-Rebar Flask-Rebar combines flask, marshmallow, and swagger for robust REST services. Features Request and Response Validation - Flask-Rebar reli

PlanGrid 223 Dec 19, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 282 Feb 11, 2021
Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development.

Flask-Starter Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development. It has all the r

Kundan Singh 259 Dec 26, 2022
Brandnew-flask is a CLI tool used to generate a powerful and mordern flask-app that supports the production environment.

Brandnew-flask is still in the initial stage and needs to be updated and improved continuously. Everyone is welcome to maintain and improve this CLI.

brandonye 4 Jul 17, 2022
Flask Project Template A full feature Flask project template.

Flask Project Template A full feature Flask project template. See also Python-Project-Template for a lean, low dependency Python app. HOW TO USE THIS

Bruno Rocha 96 Dec 23, 2022
A Fast API style support for Flask. Gives you MyPy types with the flexibility of flask

Flask-Fastx Flask-Fastx is a Fast API style support for Flask. It Gives you MyPy types with the flexibility of flask. Compatibility Flask-Fastx requir

Tactful.ai 18 Nov 26, 2022
Flask-app scaffold, generate flask restful backend

Flask-app scaffold, generate flask restful backend

jacksmile 1 Nov 24, 2021
Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure.

Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure. All the required libraries are already installed easily to use in any big project.

Ajay kumar sharma 5 Jun 14, 2022
Pf-flask-rest-com - Flask REST API Common Implementation by Problem Fighter Library

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Rest-Com Docu

Problem Fighter 3 Jan 15, 2022
Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python

Flask-Discord-Bot-Dashboard A simple discord Bot dashboard created in Flask Pyth

Ethan 8 Dec 22, 2022
Open-source Flask Sample built on top of flask-dance library

Open-source Flask Sample built on top of flask-dance library. The project implements the social login for Github and Twitter - Originally coded by TestDriven.IO.

App Generator 4 Jul 26, 2022
Flask-redmail - Email sending for Flask

Flask Red Mail: Email Sending for Flask Flask extension for Red Mail What is it?

Mikael Koli 11 Sep 23, 2022
Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications.

Flask Sitemapper Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications. This allows you to create a nice and

null 6 Jan 6, 2023
Flask-template - A simple template for make an flask api

flask-template By GaGoU :3 a simple template for make an flask api notes: you ca

GaGoU 2 Feb 17, 2022
Python Flask API service, backed by DynamoDB, running on AWS Lambda using the traditional Serverless Framework.

Serverless Framework Python Flask API service backed by DynamoDB on AWS Python Flask API service, backed by DynamoDB, running on AWS Lambda using the

Andreu Jové 0 Apr 17, 2022
REST API built using flask framework that used for managing bookmarks by individual users.

Bookmarks REST API REST API built using flask framework that used for managing bookmarks by individual users. API Consumers Note This app is built usi

Venkatesh Tantravahi 1 Dec 27, 2021
Flask Web DRY full-stack framework by Problem Fighter

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Web Documentation Install and update using pip: pip install -U PF-Flask-Web Please

Problem Fighter 2 Jan 20, 2022