I am writing my website's backend using Flask and Python 2.7, and have run into a bit of a problem. I like to use classes to enclose my functions, it makes things neat for me and helps me keep everything modular. One problem I'm having, though, is that the decorators flask uses for routing doesn't preserve the self variable. I use this for accessing the loadDb method of the class that its in. See below. Anyone have any ideas why this is happening, and know how I could solve this, or even if there is a way to solve this?
class Test(object):blueprint = Blueprint("Test", __name__)def __init__(self, db_host, db_port):self.db_host = db_hostself.db_port = db_portdef loadDb(self):return Connection(self.db_host, self.db_port)@blueprint.route("/<var>")def testView(var): # adding self here gives me an errorreturn render_template("base.html", myvar=self.loadDb().find({"id": var})