# Path: app.py



import os
import sys
from uuid import uuid4
from datetime import datetime, timedelta
from flask.sessions import SessionInterface, SessionMixin
from werkzeug.datastructures import CallbackDict
from pymongo import MongoClient
from app import app
# -*- coding: utf-8 -*-
"""
    sessions.mongodb_session
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Server-side sessions with MongoDB (pymongo)
    http://flask.pocoo.org/snippets/110/
"""

sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))




class MongoSession(CallbackDict, SessionMixin):

    def __init__(self, initial=None, sid=None):
        CallbackDict.__init__(self, initial)
        self.sid = sid
        self.modified = False


class MongoSessionInterface(SessionInterface):

    def __init__(self, host='localhost', port=27017,
                 db='', collection='sessions'):
        client = MongoClient(host, port)
        self.store = client[db][collection]


# Path: app.py



# Path: sessions/mongodb_session.py
import os
import sys
from uuid import uuid4
from datetime import datetime, timedelta
from flask.sessions import SessionInterface, SessionMixin
from werkzeug.datastructures import CallbackDict
from pymongo import MongoClient
from app import app

# -*- coding: utf-8 -*-
"""
    sessions.mongodb_session
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Server-side sessions with MongoDB (pymongo)
    http://flask.pocoo.org/snippets/110/
"""

sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))




class MongoSession(CallbackDict, SessionMixin):

    def __init__(self, initial=None, sid=None):
        CallbackDict.__init__(self, initial)
        self.sid = sid
        self.modified = False


class MongoSessionInterface(SessionInterface):

    def __init__(self, host='localhost', port=27017,
                 db='', collection='sessions'):
        client = MongoClient(host, port)
        self.store = client[db][collection]


    def open_session(self, app, request):