当尝试将 Mako 与 Pyramid 框架一起使用时,进入 development.ini 文件并添加行
mako.directories = TestProject:templates
在:
[app:TestProject]
然后在模板子目录中创建一个名为 template.mako 的简单 html 文件,我得到:
ImportError: No module named TestProject
但我不明白为什么在上述步骤之后会发生这种情况。为什么这些步骤会产生 importError?
错误的更多细节:
URL: http://localhost:6543/
File 'C:\\env\\lib\\site-packages\\weberror-0.10.3-py2.7.egg\\weberror\\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\router.py', line 158 in __call__
response = view_callable(context, request)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\config.py', line 2839 in _rendered_view
context)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\renderers.py', line 294 in render_view
request=request)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\renderers.py', line 322 in render_to_response
result = self.render(value, system_values, request=request)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\renderers.py', line 298 in render
renderer = self.renderer
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\decorator.py', line 17 in __get__
val = self.wrapped(inst)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\renderers.py', line 280 in renderer
return factory(self)
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\mako_templating.py', line 77 in renderer_factory
directories = [ abspath_from_asset_spec(d) for d in directories ]
File 'C:\\env\\lib\\site-packages\\pyramid-1.0-py2.7.egg\\pyramid\\asset.py', line 207 in abspath_from_asset_spec
return pkg_resources.resource_filename(pname, filename)
File 'C:\\env\\lib\\site-packages\\setuptools-0.6c12dev_r88124-py2.7.egg\\pkg_resources.py', line 881 in resource_filename
File 'C:\\env\\lib\\site-packages\\setuptools-0.6c12dev_r88124-py2.7.egg\\pkg_resources.py', line 201 in get_provider
ImportError: No module named TestProject