Skip to content

fab-quick-start utility to generate FAB AppBuilder views.py, and FAB Quick Start Guide (wiki)

License

Notifications You must be signed in to change notification settings

alitrack/fab-quick-start

 
 

Repository files navigation

FAB Quick Start Utility - build views.py

The fab-quick-start command line utility generates Flask Application Builder (FAB) views.py files, to create instant multi-page, multi-table apps.

Update - Jan 26, 2021: checkout ApiLogicServer - create a complete JSON:API for your database, with LogicBank, and a basic web app

Use this FAB Quick Start Guide to create the application below in 10 minutes.

Features

Generated fab pages look as shown below:

  1. Multi-page: apps incude 1 page per table
  2. Multi-table: pages include related_views for each related child table, and join in parent data
  3. Favorite field first: first-displayed field is "name", or contains "name" (configurable)
  4. Predictive joins: favorite field of each parent is shown (product name - not product id)
  5. Ids last: such boring fields are not shown on lists, and at the end on other pages

Background

Flask Application Builder (FAB) provides a rapid means for building web pages for database apps, based on Python, Flask and sqlalchemy. Use this Quick Start Guide to create the application above in 10 minutes.

Recall that creating the views.py file can be tedious. This utility generates the views.py file from the models.py file, to save time and reduce learning curve.

Usage (on your project)

First, create a fab project (e.g., see the Quick Start Guide).

Then, generate the views.py file like this:

cd <project>  # fab directory containing `config.py` file
pip install fab-quick-start
fab-quick-start run

Copy the console output to your views.py file, and run fab / flask app:

export FLASK_APP=app
flask run

Parameters

The simple run command will request 2 parameters, and output to the console. You can specify parameters and output via command line arguments, like this:

fab-quick-start run --favorites="name description" --non_favorites="id" > app/views.py

where

  • favorites: names()) used to find "favorite fields". Fields named with these words, or containing these words, are placed at the start of lists and show pages. Your values might reflect your language, and your database naming conventions.
  • non_favorites: name(s) used to find fields to be placed at the end of list / show pages.
  • the > pipes the output to a file (which is overwritten).

Foreign Keys

A key FAB service is automatic page navigations to see related data. These depend on Foreign Key relationships. Note statistics are shown in the last lines of the generated view.py file.

If they are not present, add them to your models.py file, or (better) to your schema.


Explore fab-quick-start

To use this project:

git clone https://github.com/valhuber/fab-quick-start.git
cd fab-quick-start
virtualenv venv
source venv/bin/activate
cd nw/basic_web_app
export FLASK_APP=app
flask run

Use this to explore the FAB Quick Start Utility further.

Now with Logic

FAB works with Logic Bank, which employs rules and Python to dramatically reduce and simplify backend code for business logic.

Acknowledgements

Many thanks to

  • Daniel Vaz Gaspar, the creator of FAB, for his help and guidance
  • Katrina Huber-Juma, for Python help and final review
  • Tyler Band, for early testing
  • Achim Götz, for reporting a bug in examples

About

fab-quick-start utility to generate FAB AppBuilder views.py, and FAB Quick Start Guide (wiki)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.7%
  • Other 0.3%