bridgedb.HTTPServer.ReCaptchaProtectedResource.checkSolution() doesn't expect a deferred
From bridgedb-0.1.5, bridgedb.HTTPServer.ReCaptchaProtectedResource.checkSolution()
expects a bool
for the solution
internal variable, not a t.i.defer.Deferred
:
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 1349, in dataReceived
finishCallback(data[contentLength:])
File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 1563, in _finishRequestBody
self.allContentReceived()
File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 1618, in allContentReceived
req.requestReceived(command, path, version)
File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 773, in requestReceived
self.process()
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/web/server.py", line 132, in process
self.render(resrc)
File "/usr/lib/python2.7/dist-packages/twisted/web/server.py", line 167, in render
body = resrc.render(self)
File "/usr/lib/python2.7/dist-packages/twisted/web/resource.py", line 216, in render
return m(request)
File "/srv/bridges.torproject.org/local/lib/python2.7/site-packages/bridgedb-0.1.5_dirty-py2.7.egg/bridgedb/HTTPServer.py", line 470, in render_POST
return CaptchaProtectedResource.render_POST(self, request)
File "/srv/bridges.torproject.org/local/lib/python2.7/site-packages/bridgedb-0.1.5_dirty-py2.7.egg/bridgedb/HTTPServer.py", line 220, in render_POST
if self.checkSolution(request):
File "/srv/bridges.torproject.org/local/lib/python2.7/site-packages/bridgedb-0.1.5_dirty-py2.7.egg/bridgedb/HTTPServer.py", line 432, in checkSolution
if solution.is_valid:
exceptions.AttributeError: Deferred instance has no attribute 'is_valid'
Should be easy, just reorder the current code to make solution.is_valid
be checked inside a callback function on the deferred returned from txrecaptcha.submit()
. See the test_submit_resultIsRecaptchaResponse()
unittest for an example of how it was designed to work.