Scenario
The model User has the "unique=True" option set in the "email" and "username" fields.
A row with a duplicate value in any of the two fields.
What happens
The following Traceback:
Traceback (most recent call last):
File "/home/mader/.virtualenvs/tcwa_backend/lib/python3.4/site-packages/tornado/web.py", line 1346, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/home/mader/.virtualenvs/tcwa_backend/lib/python3.4/site-packages/tornado_restless/handler.py", line 486, in post
self.finish()
File "/home/mader/.virtualenvs/tcwa_backend/lib/python3.4/site-packages/tornado/web.py", line 863, in finish
raise RuntimeError("finish() called twice. May be caused "
RuntimeError: finish() called twice. May be caused by using async operations without the @asynchronous decorator.
Proposed fix
It seems to work fine, but I am not sure there are other complications I have not yet met.
--- handler.py.orig 2015-03-15 19:43:59.000000000 +0100
+++ handler.py 2015-03-15 20:48:56.214286385 +0100
@@ -244,7 +244,8 @@
result = self.patch_single(self.parse_pk(instance_id))
self._call_postprocessor(result=result)
- self.finish(result)
+ if not self._finished:
+ self.finish(result)
def patch_many(self) -> dict:
"""
@@ -364,7 +365,8 @@
result = self.delete_single(self.parse_pk(instance_id))
self._call_postprocessor(result=result)
- self.finish(result)
+ if not self._finished:
+ self.finish(result)
def delete_many(self) -> dict:
"""
@@ -455,7 +457,8 @@
result = self.put_single(self.parse_pk(instance_id))
self._call_postprocessor(result=result)
- self.finish(result)
+ if not self._finished:
+ self.finish(result)
put_many = patch_many
put_single = patch_single
@@ -480,7 +483,8 @@
result = self.post_single()
self._call_postprocessor(result=result)
- self.finish(result)
+ if not self._finished:
+ self.finish(result)
def post_single(self):
"""
@@ -691,7 +695,8 @@
result = self.get_single(self.parse_pk(instance_id))
self._call_postprocessor(result=result)
- self.finish(result)
+ if not self._finished:
+ self.finish(result)
def get_single(self, instance_id: list) -> dict:
"""
Scenario
The model User has the "unique=True" option set in the "email" and "username" fields.
A row with a duplicate value in any of the two fields.
What happens
The following Traceback:
Proposed fix
It seems to work fine, but I am not sure there are other complications I have not yet met.