From 9b796b0eb088f8e0467fb5b70160f0dc5c15c6a3 Mon Sep 17 00:00:00 2001 From: Blake DeMarcy Date: Mon, 3 Apr 2017 03:34:50 -0500 Subject: [PATCH] move anon initialization from top to bottom --- server.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/server.py b/server.py index 1c42397..e9817c9 100644 --- a/server.py +++ b/server.py @@ -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")