Skip to content

Commit

Permalink
Add errors details on abort responses. Add an instance var on BaseHan…
Browse files Browse the repository at this point in the history
…dler to store the current session.
  • Loading branch information
gomezjdaniel committed Feb 5, 2013
1 parent f365ec8 commit 9077c27
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class Base(webapp2.RequestHandler):
def dispatch(self):
session_store = User.get_session_store()
self.session = User.get_session()
try:
super(Base, self).dispatch()
finally:
Expand Down
8 changes: 5 additions & 3 deletions ngforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def validate(self):
data = json.decode(request.body)

if not isinstance(data, dict):
webapp2.abort(403)
webapp2.abort(403, detail='not a dict')

for f in self.fields:
if not f.id in self.validations:
Expand All @@ -37,7 +37,9 @@ def validate(self):
val.input = f.id

if not val.validate(self):
webapp2.abort(403)
webapp2.abort(403,
detail='validation error, id: %s name: %s value: %s'
% (f.id, f.name, value))

return self.field_values

Expand All @@ -57,7 +59,7 @@ def field(self, id):
return self.field_values[id]

request = webapp2.get_request()
webapp2.abort(403)
webapp2.abort(403, detail='not a string, id: %s' % id)


class Validation(object):
Expand Down
4 changes: 4 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

import webapp2
from webapp2_extras import json

import unittest

from google.appengine.ext import testbed
from google.appengine.datastore import datastore_stub_util


class Base(unittest.TestCase):
Expand Down

0 comments on commit 9077c27

Please sign in to comment.