On Mon, Dec 12, 2016 at 7:27 AM, roma <dr.roman.g...@gmail.com> wrote:
> Thanks Justin, > > I believe, the whole database story has no influence on the broken pipe > error. I've commented out the whole block and leave only return line: > return HttpResponse(res, content_type="text/plain; charset=utf-8") > The error is still present. And I have no influence on that. > > I call python from js client: > > var newTrendReport = new App.TrendReport(); > newTrendReport.set('search_phrase', search_phrase); > newTrendReport.set('time_from', time_from); > newTrendReport.set('time_to', time_to); > newTrendReport.set('time_scale', time_scale); > newTrendReport.set('category', category); > newTrendReport.startExport( > > function(response){ > console.log("Successfully calculated trend report."); > App.trendPage = new App.TrendPageView(); > App.trendPage.render(response); > }, > ); > > go throw: > > App.TrendReport = Backbone.Model.extend({ > urlRoot: "/api/trend_reports/", > defaults: { > search_phrase: "", > time_from: "", > time_to: "", > time_scale: "", > category: "" > }, > > startExportSuffix: "/export_report/", > > startExport: function( successCallback, errorCallback ) { > console.log("start trend calculation"); > var that = this; > var ajaxUrl = this.startExportSuffix; > var options = { > method: "POST", > data: this.attributes, > contentType: "application/json;charset=UTF-8", > dataType: "json", > > error: errorCallback, > success: successCallback > }; > console.log("start trend export sync"); > App.ajax(ajaxUrl, options); > } > > }); > > and come in export_report method. > > My urls.py: > > url(r'^export_report', ensure_csrf_cookie(views.export_report), > name="export_report"), > -- > https://mail.python.org/mailman/listinfo/python-list > I'm not super familiar with the way backbone does http requests, but something seems off about the startExport function. It seems to me that you are sending a post request to "/export_report/" which is an endpoint that I'm guessing is nested in an include from "/api/trend_reports/". However, it looks like the error you're getting above says you aren't sending the request to "https://root.com/api/trend_reports/export_report/". Instead, you are sending the request to "https://root.com/export_report/" . Though, I'm also not sure that's the case because that would normally throw a 404. I also noticed that you set content type to 'application/json' in your js, but the view function returns a 'text/plain' content type. Is There a reason for this? The data key in your js http function is set to the attributes variable which, as far as I can tell, does not exist. There's a lot going on here, but I think you can probably narrow it down to something in your backbone code or the way backbone handles http requests as the error you are getting is caused by the client prematurely closing the socket. It's possible backbone will stop reading the response since it isn't the same content-type as the request. -- https://mail.python.org/mailman/listinfo/python-list