Rearrange imports in previous migration.

According to mg bad things can happen if you try to do stuff outside of a
migration's upgrade() function.
Construct database queries on threads/messages from query parameters.

Summary: Currently only for exact term matching -- no regular expressions yet.

Test Plan: Unit tests to come.

Reviewers: mg, spang

Reviewed By: mg

Differential Revision: https://review.inboxapp.com/D128
Install gevent via pip instead of apt-get.

This lets us use gevent 1.0, which has more features and no external
dependencies.
First part of API (w/ migration)

Summary:
- Migration to store message `blocks` in a separate table `parts`. This change is important for future use where non-message blocks can be uploaded to a namespace. The `part` objects are attachments on messages, and inherit from the `block` foundation, which provides the appropriate hashing, IDs, and Blob storage to S3 options.

- Custom JSON Encoder: works with many of our data objects (not all yet)

- API Documentation: these are written in Markdown and live in separate category files. The Flask app handles Markdown -> HTML rendering at the `/docs` URL. CSS based on GitHub style. Table of Contents is autogenerated based on filename ordering and title metadata.

- Initial version of the API server. (See the docs for more details) The Flask server `srv.py` runs on port 5555 and most of it is broken. It uses Flask Blueprints for different URL prefixes.

- File uploads: created in proper namespace

- File downloads: smart filenames are generated based on mimetype and common extensions (inline attachments don't have filenames)

- Fix for a *huge* bug parsing messages where we replaced newlines for all binary data (not just plain text)

Test Plan: all tests pass. updated test dump included

Reviewers: spang, emfree, kav-ya

Reviewed By: spang

Differential Revision: https://review.inboxapp.com/D129
Rename Alembic migrations in the actual order

I have no idea why they don't just remove pyc files before running anything. Causes so many headaches. If you're ever having issues, try just running `find . -name '*.pyc' -delete` in your shell.
some API doc changes and merge API server requirements with main app
Support non-versioned sessions.

Sometimes you want this, either for testing or for migrations.
HTTPS proxy server
Base is special; you can't share it between projects.

Because the associated metadata object is given information about all
tables that sqlalchemy knows about, leaving this object shared totally
messes up the inbox.sqlalchemy.revision tests since it tries to make
//all// tables for inbox in sqlite!
[SCHEMA] Save more folder names.
[SCHEMA] Separate tables for backend folders/labels and Inbox labels.

Following a design discussion, we are splitting our notion of folders
and labels into two different things: folders/labels from the account
backend (e.g. Gmail), and Inbox-specific labels.
Port Gmail code to new folder/label schema.

With this change, we rip out folder name translation for Gmail labels
and store them as-is. Special Inbox labels will be provided via
different queries; they no longer are stored specially in the database.