使用production.ini托管金字塔应用程序时出现服务器错误

时间:2014-05-26 15:05:37

标签: python pyramid production waitress

我有一个金字塔项目在使用development.ini托管时工作正常,但是一旦我使用production.ini,我在浏览器中出现此错误:

Internal Server Error
The server encountered an unexpected internal server error
(generated by waitress)

并登录终端:

Starting subprocess with file monitor
Starting server in PID 5912.
serving on http://0.0.0.0:6543
2014-05-26 16:54:23,139 ERROR [waitress][Dummy-2] Exception when serving /
Traceback (most recent call last):
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/channel.py", line 337, in service
    task.service()
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/router.py", line 242, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/router.py", line 217, in invoke_subrequest
    response = handle_request(request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid_tm-0.7-py2.7.egg/pyramid_tm/__init__.py", line 82, in tm_tween
    reraise(*exc_info)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid_tm-0.7-py2.7.egg/pyramid_tm/__init__.py", line 63, in tm_tween
    response = handler(request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/router.py", line 163, in handle_request
    response = view_callable(context, request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/config/views.py", line 377, in rendered_view
    context)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/renderers.py", line 418, in render_view
    return self.render_to_response(response, system, request=request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/renderers.py", line 441, in render_to_response
    result = self.render(value, system_values, request=request)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/renderers.py", line 421, in render
    renderer = self.renderer
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/decorator.py", line 37, in __get__
    val = self.wrapped(inst)
  File "/home/roman/Critical_ID/CCG_Map/local/lib/python2.7/site-packages/pyramid/renderers.py", line 404, in renderer
    'No such renderer factory %s' % str(self.type))
ValueError: No such renderer factory .mak

我复制了.ini文件中sqlalchemy.url部分下的mako.directories[app:main],我无法看到导致此错误的原因。

我使用:../bin/pserve/production.ini --reload

启动服务器

我错过了什么?

1 个答案:

答案 0 :(得分:2)

这是因为最新版本的Pyramid默认情况下不需要/安装Mako的模板引擎。要解决此错误,请记录HERE,您必须做两件事:

  1. 确保已安装pyramid_mako包。一种方法是将“pyramid_mako”添加到软件包install_requires文件的setup.py部分,然后重新运行setup.py develop

    setup(
        #...
        install_requires=[
            'pyramid_mako',         # new dependency
            'pyramid',
            #...
        ],
    )
    
  2. 在应用程序中实例化Pyramid配置程序的部分(通常是项目的main()文件中的__init__.py函数),告诉Pyramid包含pyramid_mako includeme:< / p>

    config = Configurator(.....)
    config.include('pyramid_mako')