0

我有一个金字塔项目,在使用 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

我错过了什么?

4

1 回答 1

2

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

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

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

    config = Configurator(.....)
    config.include('pyramid_mako')
    
于 2014-05-26T17:24:59.490 回答