找不到模板,在Webfaction上部署Pyramid [英] template not found, deploying Pyramid on Webfaction

查看:125
本文介绍了找不到模板,在Webfaction上部署Pyramid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的Web应用程序部署到Webfaction,基本示例正常运行,我在模板中得到了TemplateNotFound,该模板使用Jinja2扩展了基本模板.这是我的项目树:

I'm trying to deploy my webapp to Webfaction, the basic example is working correctly, I got a TemplateNotFound in a template that extends a basic template using Jinja2. Here is my project tree:

/webapps
    /myapp
        development.ini
        production.ini
        /bin
    /theapp
        /Project
          setup.py
          /project
              __init__.py
              views.py
              /templates
                  base.jinja2
                  home.jinja2
              /static

_ init _.py

_init_.py

config.include('pyramid_jinja2')
config.add_jinja2_search_path("templates")

home.jinja2

{% extends "templates/base.jinja2" %}

更清楚地说,该项目在本地工作,我知道它与模板路径有关,我不确定如何设置它,我尝试了许多不同的方法,无论如何这是回溯:

To be more clear, the project works locally I know it's something with the template path, I'm not sure how to set it, I tried many different ways, anyways this is the traceback:

  File "..webapps/myapp/myapp/Project/project/templates/home.jinja2", line 1, in top-level template code
    {% extends "templates/base.jinja2" %}
  File "..webapps/myapp/lib/python2.7/site-packages/pyramid_jinja2-1.8-py2.7.egg/pyramid_jinja2/__init__.py", line 193, in get_source
    raise TemplateNotFound(name=ex.name, message=message)
TemplateNotFound: templates/base.jinja2; asset=..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates/base.jinja2; searchpath=['..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates']

如果这是我的错误,请帮助我为模板设置正确的路径.

Please help me set the correct path to templates, if that is my mistake.

推荐答案

由于搜索路径为'..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates',这告诉我您使用python setup.py install将应用程序安装为鸡蛋.到目前为止,以这种方式分发应用程序最常见的陷阱是,在打包应用程序时,需要MANIFEST.in文件才能使其包含静态资产. python setup.py develop而是将应用程序运行到目录之外,并且不会遭受该问题的困扰.我希望如果您解压缩egg文件,您将不会在其中找到模板.

Since the search path is '..webapps/myapp/lib/python2.7/site-packages/Project-0.0-py2.7.egg/project/templates', that tells me you installed your application as an egg using python setup.py install. By far the most common pitfall of distributing your app in this way is that it requires a MANIFEST.in file when packaging your application in order for it to include static assets. python setup.py develop runs the application out of the directory instead, and does not suffer from that problem. I expect that if you unzip your egg file you will not find your templates inside.

这篇关于找不到模板,在Webfaction上部署Pyramid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆