2013-05-03 23 views
1

我已经完成了打印pdf功能。我使用金字塔,wkhtmltopdfjinja2生成pdf。它工作正常gunicorn。但是,当我将其部署到生产环境时(我使用马尔可夫在生产环境中运行)时,该函数将失败,并且不会显示任何错误消息。源代码如下:无法回复马戏团中的pdf文件

pdf_renderer = PDFRenderer() 

request = self.request 

html = render('test.jinja2' , pdf_data, request) 

response = request.response 
response.write(pdf_renderer(html)) 
response.content_type = 'application/pdf' 
response.headerlist.append(('Content-Disposition', 'attachment; filename='test.pdf')) 

#Everything is ok except the final statement. 
#circusd cannot run the statement "return response" 
#However, gunicorn can do it 
return response 

那么,您对我的问题有什么建议或想法吗?它是如此直接,我不明白为什么它工作正常gunicorncircusd

+0

通过'circusd'你是指chaussette,如果是的话,后端是什么?马戏团不是WSGI服务器,应该对可发送的响应类型没有影响。 – 2013-05-03 08:20:44

回答

1

尝试将content_length失败。有可能您使用的WSGI服务器不支持流式响应(如果您使用.write().app_iter而不设置content_length会发生这种情况。对于你的使用案例,更有可能你只需设置body就可以为你处理所有事情。

response.body = pdf_renderer(html)