SQLAlchemy and Falcon - session initialization : <p>I'm wondering where the best place would be to create a scoped session for use in falcon.</p>

<p>From reading the flask-sqlalchemy code, it, in a round about way, does something like this:</p>

<pre><code>from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

try:
    from greenlet import get_current as get_ident
except ImportError:
    try:
        from thread import get_ident
    except ImportError:
        from _thread import get_ident

connection_uri = 'postgresql://postgres:@localhost:5432/db'
engine = create_engine(connection_uri)
session_factory = sessionmaker(bind=engine)
session_cls = scoped_session(session_factory, scopefunc=get_ident)
session = session_cls()
</code></pre>

<p>Would this work for falcon?  Will the <code>get_ident</code> func "do the right thing" when using gunicorn?</p>
