def setup(self): #engine = create_engine('sqlite:///:memory:', echo=False) #Session = sessionmaker(bind=engine) #self.session = Session() engine, self.session=dbase.setup_db(DBASE_FILE) # You probably need to create some tables and # load some test data, do so here. # To create tables, you typically do: classes.DaBase.metadata.create_all(engine)
currentuser=None currentuser=whosdb.getUserForNick(currentuser, "*****@*****.**") rahuldave=whosdb.addUser(currentuser, dict(nick='*****@*****.**', email="*****@*****.**")) whosdb.addUserToApp(currentuser, '[email protected]/app:publications', rahuldave, None) #rahuldave.applicationsin.append(adspubsapp) mlg=whosdb.addGroup(currentuser, dict(name='ml', description="Machine Learning Group", creator=rahuldave)) whosdb.commit() jayluker=whosdb.addUser(currentuser, dict(nick='*****@*****.**', email="*****@*****.**")) whosdb.addUserToApp(currentuser, '[email protected]/app:publications', jayluker, None) #jayluker.applicationsin.append(adspubsapp) whosdb.commit() whosdb.inviteUserToGroup(currentuser, '[email protected]/group:ml', jayluker, None) whosdb.commit() whosdb.acceptInviteToGroup(currentuser, '[email protected]/group:ml', jayluker, None) whosdb.addGroupToApp(currentuser, '[email protected]/app:publications', '[email protected]/group:public', None ) #public.applicationsin.append(adspubsapp) #rahuldavedefault.applicationsin.append(adspubsapp) whosdb.commit() print "ending init" if __name__=="__main__": import os, os.path if os.path.exists(config.DBASE_FILE): os.remove(config.DBASE_FILE) engine, db_session = dbase.setup_db(config.DBASE_FILE) dbase.init_db(engine) initialize_application(db_session) initialize_testing(db_session)
from dbase import setup_db import whos from flask import Flask, request, session, g, redirect, url_for, \ abort, render_template, flash, escape, make_response, jsonify engine, db_session=setup_db("/tmp/adsgut.db") app = Flask(__name__) @app.before_request def before_request(): g.db=whos.Whosdb(db_session) if session.has_key('username'): g.currentuser=g.db.getUserForNick(None, session['username']) else: g.currentuser=None @app.teardown_request def shutdown_session(exception=None): #g.db.commit() g.db.remove() from poalflask import * app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT' if __name__=='__main__': app.debug=True