== Frameworks and Tools

We attempt to use the same set of frameworks and tools across projects
to minimize the number of frameworks developers must keep in their
heads.

=== Python

==== Flask

http://flask.pocoo.org/[Flask] is a web microframework for Python based
on http://werkzeug.pocoo.org/[Werkzeug] and
http://jinja.pocoo.org/[Jinja 2]. It is our preferred framework and all
new applications should use it unless there is a very good reason not to
do so.

[NOTE]
====
For historical reasons, you may find applications that don't use Flask.
Other frameworks currently in use include
https://www.djangoproject.com/[Django] and
http://docs.pylonsproject.org/projects/pyramid/en/latest/[Pyramid].
====

Flask is designed to be extensible, so it's common to use extensions
with the core flask library. A few common extensions are documented
below.

===== Flask-SQLAlchemy

http://flask-sqlalchemy.pocoo.org/[Flask-SQLAlchemy] integrates Flask
with SQLAlchemy. It will configure a scoped session for you, set up a
declarative base class, and provide a convenient
`flask_sqlalchemy.BaseQuery` sub-class for you.

===== SQLAlchemy Helpers

https://github.com/fedora-infra/sqlalchemy-helpers/[SQLAlchemy-Helpers] is an
alternative to using Flask-SQLAlchemy if you need your models to be usable
from outside Flask.

==== SQLAlchemy

http://www.sqlalchemy.org/[SQLAlchemy] is an SQL toolkit and Object
Relational Mapper. It provides a core set of tools (surprisingly called
SQLAlchemy Core) for working with SQL databases, as well as an Object
Relational Mapper (SQLAlchemy ORM) which is built using SQLAlchemy Core.

SQLAlchemy is quite flexible and provides a myriad of options. We use
SQLAlchemy with its
http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/index.html[Declarative]
extension to map SQL tables to Python classes. Once mapped, instances of
those Python classes are created from database rows using the
http://docs.sqlalchemy.org/en/latest/orm/session.html[Session]
interfaces.
