move anon initialization from top to bottom

pull/4/head
Blake DeMarcy 2017-04-03 03:34:50 -05:00
parent 2fd58556fc
commit 9b796b0eb0
1 changed files with 14 additions and 15 deletions

View File

@ -9,21 +9,6 @@ import json
dbname = "data.sqlite"
# user anonymity is achieved in the laziest possible way: a literal user
# named anonymous. may god have mercy on my soul.
_c = sqlite3.connect(dbname)
try:
db.anon = db.user_resolve(_c, "anonymous")
if not db.anon:
db.anon = db.user_register(
_c, "anonymous", # this is the hash for "anon"
"5430eeed859cad61d925097ec4f53246"
"1ccf1ab6b9802b09a313be1478a4d614")
finally:
_c.close()
del _c
def api_method(function):
"""
A wrapper that handles encoding of objects and errors to a
@ -285,6 +270,20 @@ class API(object):
test.exposed = True
# user anonymity is achieved in the laziest possible way: a literal user
# named anonymous. may god have mercy on my soul.
_c = sqlite3.connect(dbname)
try:
db.anon = db.user_resolve(_c, "anonymous")
if not db.anon:
db.anon = db.user_register(
_c, "anonymous", # this is the hash for "anon"
"5430eeed859cad61d925097ec4f53246"
"1ccf1ab6b9802b09a313be1478a4d614")
finally:
_c.close()
del _c
def run():
cherrypy.quickstart(API(), "/api")