# Path: cliche/work.py
# class Trope(Base):  # FIXME: Temporary, It not extend Nameable.
#     """Tropes"""
# 
#     #: (:class:`int`) The primary key integer.
#     id = Column(Integer, primary_key=True)
# 
#     #: (:class:`str`) Trope name
#     name = Column(String, nullable=False)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkTrope`.
#     work_tropes = relationship('WorkTrope',
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Work`.
#     works = relationship(lambda: Work, secondary='work_tropes',
#                          collection_class=set)
# 
#     __tablename__ = 'tropes'
#     __repr_columns__ = id, name
# 
# Path: cliche/web/adv_search.py
# def result():
# 
# Path: cliche/web/db.py
# def get_database_engine():
# def get_database_engine_options():
# def get_session():
# def close_session(exception=None):
# def setup_session(app):
# 
# Path: cliche/web/db.py
# def setup_session(app):
#     """Setup the ``app`` to be able to use :data:`session`.
# 
#     :param app: the Flask application to setup
#     :type app: :class:`~flask.Flask`
# 
#     """
#     app.teardown_appcontext(close_session)
# 
# Path: cliche/web/ontology.py
# def work_list():
# def work_page(title):
# def trope_list():
# def trope_page(name):
# 
# Path: cliche/web/social/oauth.py
# class Version(enum.Enum):
# class OAuthVendorConverter(BaseConverter):
# def login(vendor):
# def oauth_authorized(vendor):
# def make_account(credential_table, name, user_id):
#     def __init__(self, url_map):
#     def to_python(self, value):
#     def to_url(self, value):
# 
# Path: cliche/web/user.py
# def logout():


import datetime
import json
import logging
import urllib.parse
from flask import Flask, current_app, g, render_template
from flask import session as flask_session
from flask_oauthlib.client import OAuth
from raven.contrib.flask import Sentry
from ..user import User
from ..work import Trope
from .adv_search import adv_search_bp
from .db import session as sa_session
from .db import setup_session
from .ontology import ontology
from .social.oauth import OAuthVendorConverter, oauth_app
from .user import user_app
""":mod:`cliche.web.app` --- Flask application object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"""




__all__ = 'app', 'check_login_status', 'index', 'setup_sentry'


#: (:class:`flask.Flask`) The Flask application object.
app = Flask(__name__, template_folder='templates')
oauth = OAuth()

setup_session(app)
oauth.init_app(app)

app.url_map.converters['oauth_vendor'] = OAuthVendorConverter

app.register_blueprint(ontology)
app.register_blueprint(user_app)

# Path: cliche/work.py
# class Trope(Base):  # FIXME: Temporary, It not extend Nameable.
#     """Tropes"""
# 
#     #: (:class:`int`) The primary key integer.
#     id = Column(Integer, primary_key=True)
# 
#     #: (:class:`str`) Trope name
#     name = Column(String, nullable=False)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkTrope`.
#     work_tropes = relationship('WorkTrope',
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Work`.
#     works = relationship(lambda: Work, secondary='work_tropes',
#                          collection_class=set)
# 
#     __tablename__ = 'tropes'
#     __repr_columns__ = id, name
# 
# Path: cliche/web/adv_search.py
# def result():
# 
# Path: cliche/web/db.py
# def get_database_engine():
# def get_database_engine_options():
# def get_session():
# def close_session(exception=None):
# def setup_session(app):
# 
# Path: cliche/web/db.py
# def setup_session(app):
#     """Setup the ``app`` to be able to use :data:`session`.
# 
#     :param app: the Flask application to setup
#     :type app: :class:`~flask.Flask`
# 
#     """
#     app.teardown_appcontext(close_session)
# 
# Path: cliche/web/ontology.py
# def work_list():
# def work_page(title):
# def trope_list():
# def trope_page(name):
# 
# Path: cliche/web/social/oauth.py
# class Version(enum.Enum):
# class OAuthVendorConverter(BaseConverter):
# def login(vendor):
# def oauth_authorized(vendor):
# def make_account(credential_table, name, user_id):
#     def __init__(self, url_map):
#     def to_python(self, value):
#     def to_url(self, value):
# 
# Path: cliche/web/user.py
# def logout():


# Path: cliche/web/app.py
import datetime
import json
import logging
import urllib.parse
from flask import Flask, current_app, g, render_template
from flask import session as flask_session
from flask_oauthlib.client import OAuth
from raven.contrib.flask import Sentry
from ..user import User
from ..work import Trope
from .adv_search import adv_search_bp
from .db import session as sa_session
from .db import setup_session
from .ontology import ontology
from .social.oauth import OAuthVendorConverter, oauth_app
from .user import user_app

""":mod:`cliche.web.app` --- Flask application object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"""




__all__ = 'app', 'check_login_status', 'index', 'setup_sentry'


#: (:class:`flask.Flask`) The Flask application object.
app = Flask(__name__, template_folder='templates')
oauth = OAuth()

setup_session(app)
oauth.init_app(app)

app.url_map.converters['oauth_vendor'] = OAuthVendorConverter

app.register_blueprint(ontology)
app.register_blueprint(user_app)

app.register_blueprint(oauth_app)