This is a project implementing the blog post by Mbithe Nzomo.
Prerequisites
-
Python 2.7
-
virtualenv
-
Mysql
$ brew update && brew install mysql
-
Flask
$ pip install Flask
Resources:
-
And might add some of the feature from The Flask Mega-Tutorial.
The following list is some of the features might be used for User Portal:
Known Problems
-
flask development mode WARNING
$ flask run * Serving Flask app "run.py" * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: off
Solution: Add environment variable
FLASK_ENV
and set it to development$ export FLASK_ENV=development
-
ValueError when click on Assign in employees admin page
file "APP_ROOT/venv/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/fields.py", line 189, in get_pk_from_identity ValueError: too many values to unpack
Solution(for now): Modify line 189 in
fields.py
from188 def get_pk_from_identity(obj): 189 cls, key = identity_key(instance=obj) 190 return ':'.join(text_type(x) for x in key)
to
188 def get_pk_from_identity(obj): 189 cls, key = identity_key(instance=obj)[:2] 190 return ':'.join(text_type(x) for x in key)
-
When use SQLite as database
OperationalError: (sqlite3.OperationalError) no such table
Solution: Move sqlite database file into app directory
$ mv app.db app/
-
FSADeprecationWarning while accessing database using SQLAlchemy
APP_ROOT/venv/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
Solution: Set SQLALCHEMY_TRACK_MODIFICATIONS to False/True at line 789 in flask_sqlalchemy/__init__.py
788 track_modifications = app.config.setdefault( 789 'SQLALCHEMY_TRACK_MODIFICATIONS', False 790 )