Skip to content

Commit

Permalink
Some tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmcdonnell committed Feb 21, 2012
1 parent 4a4d73d commit d92ef47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ modules installed:
* [SQLAlchemy](http://www.sqlalchemy.org/) --- A powerful SQL abstraction layer.

You will also need to run this from a web server connected to the internet, and
you will need a database of some kind (MySQL, SQLite, or PostgreSQL would all
work).
you will need a database compatible with SQL Alchemy (MySQL, SQLite, or
PostgreSQL would all work).

Copyright
---------
Expand Down
17 changes: 10 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
DEPLOYMENT_ENV = 'sandbox' # 'sandbox' or 'deploy' (the real thing)
CODE_VERSION = '1'

DATABASE = 'mysql://user:password@domain:port/dbname'
#DATABASE = 'mysql://user:password@domain:port/dbname'
DATABASE = 'sqlite://'
TABLENAME = 'turkdemo'
SUPPORTIE = True
NUMCONDS = 1
Expand Down Expand Up @@ -69,8 +70,8 @@
#----------------------------------------------
# function for authentication
#----------------------------------------------
validuname = examplename
validpw = examplepass
validuname = "examplename"
validpw = "examplepass"

def wrapper(func, args):
return func(*args)
Expand Down Expand Up @@ -282,6 +283,8 @@ def mturkroute():
hitid=request.args['hitId'],
assignid=request.args['assignmentId'],
workerid=request.args['workerId'])
else:
return render_template('error.html', errornum=HIT_ASSIGN_WORKER_ID_NOT_SET_IN_MTURK)

@app.route('/consent', methods=['GET'])
def give_consent():
Expand Down Expand Up @@ -521,9 +524,10 @@ def createdatabase(engine, metadata):
# try to load tables from a file, if that fails create new tables
try:
participants = Table(TABLENAME, metadata, autoload=True)
print "Participant table already seems to exist."
except: # can you put in the specific exception here?
# ok will create the database
print "ok will create the participant database"
print "Initializing the database."
participants = Table(TABLENAME, metadata,
Column('subjid', Integer, primary_key=True),
Column('ipaddress', String(128)),
Expand Down Expand Up @@ -564,11 +568,10 @@ def loaddatabase(engine, metadata):
engine = create_engine(DATABASE, echo=False)
metadata = MetaData()
metadata.bind = engine
if sys.argv[1]=='initdb':
if 'initdb' in sys.argv:
print "initializing database"
createdatabase(engine, metadata)
pass
elif sys.argv[1]=='server':
if 'server' in sys.argv:
print "starting webserver"
participantsdb = loaddatabase(engine, metadata)
# by default just launch webserver
Expand Down

0 comments on commit d92ef47

Please sign in to comment.