Skip to content

Commit

Permalink
Merge pull request #44 from Misaka42/master
Browse files Browse the repository at this point in the history
Fixed JSendMixin hanging up if auto_finish was disabled
  • Loading branch information
hfaran committed Jul 10, 2014
2 parents dbd2fd8 + b12e095 commit 17091bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_tornado_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class MockJSendMixinRH(jsend.JSendMixin):
def write(self, data):
self._buffer = data

def finish(self):
pass

@classmethod
@pytest.fixture(scope="class", autouse=True)
def setup(cls):
Expand Down
3 changes: 3 additions & 0 deletions tornado_json/jsend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def success(self, data):
call. If the call returns no data, data should be set to null.
"""
self.write({'status': 'success', 'data': data})
self.finish()

def fail(self, data):
"""There was a problem with the data submitted, or some pre-condition
Expand All @@ -30,6 +31,7 @@ def fail(self, data):
the response object's keys SHOULD correspond to those POST values.
"""
self.write({'status': 'fail', 'data': data})
self.finish()

def error(self, message, data=None, code=None):
"""An error occurred in processing the request, i.e. an exception was
Expand All @@ -51,3 +53,4 @@ def error(self, message, data=None, code=None):
if code:
result['code'] = code
self.write(result)
self.finish()

0 comments on commit 17091bd

Please sign in to comment.