かぎ針編みライブラリを使用してdjangoビューを実行していますが、. 私は本当に単純ですが、経験がなく、解決方法がわかりません
Internal Server Error: /clocking/request/send_fence_to_device/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in get_response
response = middleware_method(request, response)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/locale.py", line 29, in process_response
if (response.status_code == 404 and
AttributeError: 'EventualResult' object has no attribute 'status_code'
ERROR:django.request:Internal Server Error: /clocking/request/send_fence_to_device/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in get_response
response = middleware_method(request, response)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/locale.py", line 29, in process_response
if (response.status_code == 404 and
AttributeError: 'EventualResult' object has no attribute 'status_code'
{'answer': 'ok'}
私のコードビュー
@run_in_reactor
def send_fence_to_device (request):
device_id = request.GET['device_id']
fence_id = request.GET['fence_id']
fnc = Fence.objects.get(id=fence_id)
dev = Device.objects.get(id=device_id)
try:
devLog = dev.devicelog_set.filter(device_id=device_id, status = True).order_by('created').reverse()[:1].all()[0]
except:
print "error"
return HttpResponse(simplejson.dumps(0), mimetype='application/json')
params = simplejson.loads(fnc.other)
lttdlgtd = simplejson.loads(fnc.points)
strCommand = ".geo.%s,%s,%s,%s,%s,%s,%s,%s,%s*" % (params['identificator'], fnc.name[:4], round(float(lttdlgtd[0][0]), 4), round(float(lttdlgtd[0][1]), 4), round(float(fnc.radius), 4), params['time_to_arrive'], params['fence_class'], params['tolerance'], 1)
print strCommand
creator = ClientCreator(reactor, AMP)
cmmdDeferred = creator.connectTCP('127.0.0.1', 8750)
def connected(protocol):
return protocol.callRemote(
AmpProcessor,
proto=str('TELCOMIP'),
imei=str(devLog.ip),
ip=str(devLog.ip),
port=str(devLog.port),
cmmd=str(strCommand)
)
cmmdDeferred.addCallback(connected)
#def processed(result):
# print result
#cmmdDeferred.addCallback(processed)
def done(result):
reactor.stop()
return HttpResponse(simplejson.dumps(result), mimetype='application/json')
cmmdDeferred.addCallback(done)
#return HttpResponse(simplejson.dumps(1), mimetype='application/json')