]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Use a dummy session variable.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 8 Sep 2012 18:37:18 +0000 (14:37 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 8 Sep 2012 18:37:18 +0000 (14:37 -0400)
A little while ago I moved down the creation of the actual
DBSession() below the precondition checks to avoid unnecessary
rollback transactions. What I didn't do was check if the session
existed before using it, so when precondition checks failed I was
calling a variable that wasn't defined yet (another exception).
This adds a dummy session variable that I can check before rolling
back, avoiding more exceptions.

xonstat/views/submission.py

index d17292d8b38fc98b5358a57559be90085e130198..c248f424017c8b1ca3f9c745d58acb77bf91beed 100644 (file)
@@ -562,6 +562,9 @@ def stats_submit(request):
     Entry handler for POST stats submissions.
     """
     try:
+        # placeholder for the actual session
+        session = None
+
         log.debug("\n----- BEGIN REQUEST BODY -----\n" + request.body +
                 "----- END REQUEST BODY -----\n\n")
 
@@ -648,5 +651,6 @@ def stats_submit(request):
         log.debug('Success! Stats recorded.')
         return Response('200 OK')
     except Exception as e:
-        session.rollback()
+        if session:
+            session.rollback()
         return e