# Path: app.py



import os
import sys
import cPickle as pickle
import base64
import hmac
import hashlib
import random
import string
import datetime
from uuid import uuid4
from collections import OrderedDict
from werkzeug.datastructures import CallbackDict
from flask.sessions import SessionInterface, SessionMixin
from app import app
            return self.new_session()

        # This assumes the file is correct, if you really want to
        # make sure the session is good from the server side, you
        # can re-calculate the hmac

        if hmac_digest != digest:
            print "Invalid HMAC for session"
            return self.new_session()

        return ManagedSession(data, sid=sid, randval=randval, hmac_digest=hmac_digest)

    def put(self, session):
        'Store a managed session'
        print "Storing session: %s" % session.sid

        if not session.hmac_digest:
            session.sign(self.secret)

        fname = os.path.join(self.path, session.sid)
        with open(fname, 'w') as f:
            pickle.dump((session.randval, session.hmac_digest, dict(session)), f)


class ManagedSessionInterface(SessionInterface):
    def __init__(self, manager, skip_paths, cookie_timedelta):
        self.manager = manager
        self.skip_paths = skip_paths
        self.cookie_timedelta = cookie_timedelta


# Path: app.py



# Path: sessions/file_session.py
import os
import sys
import cPickle as pickle
import base64
import hmac
import hashlib
import random
import string
import datetime
from uuid import uuid4
from collections import OrderedDict
from werkzeug.datastructures import CallbackDict
from flask.sessions import SessionInterface, SessionMixin
from app import app

            return self.new_session()

        # This assumes the file is correct, if you really want to
        # make sure the session is good from the server side, you
        # can re-calculate the hmac

        if hmac_digest != digest:
            print "Invalid HMAC for session"
            return self.new_session()

        return ManagedSession(data, sid=sid, randval=randval, hmac_digest=hmac_digest)

    def put(self, session):
        'Store a managed session'
        print "Storing session: %s" % session.sid

        if not session.hmac_digest:
            session.sign(self.secret)

        fname = os.path.join(self.path, session.sid)
        with open(fname, 'w') as f:
            pickle.dump((session.randval, session.hmac_digest, dict(session)), f)


class ManagedSessionInterface(SessionInterface):
    def __init__(self, manager, skip_paths, cookie_timedelta):
        self.manager = manager
        self.skip_paths = skip_paths
        self.cookie_timedelta = cookie_timedelta


    def get_expiration_time(self, app, session):