我工作过Safari的金字塔教程pyramid.httpexceptions.HTTPNotFound:资源找不到
Python和金字塔框架
WEB应用我views.py
文件里有我下面的代码有问题:
@property
def current(self):
todo_id = self.request.matchdict.get('id')
todo = sample_todos.get(todo_id)
if not todo:
raise HTTPNotFound()
return todo
特别是当下面的视图函数调用这个属性时
@view_config(route_name='view', renderer='templates/view.jinja2')
def view(self):
return dict(todo=self.current)
当我运行的应用程序
http://0.0.0.0:6543/5
不会触发预期
HTTPNotFound()
,请参见下面的路线。
config.add_route('view', '/{id}')
错误日志返回:
File "/Users/alex/zdev/t-oreilly/mysite/views.py", line 50, in view
return dict(todo=self.current)
File "/Users/alex/zdev/t-oreilly/mysite/views.py", line 25, in current
raise HTTPNotFound()
pyramid.httpexceptions.HTTPNotFound: The resource could not be found.
在浏览器女服务员返回默认的服务器错误。
什么是删除此错误的正确方法?
我已上载该作品github,提交aaf562e
教程链接here,对于那些渴望帮助,它可以与他们10天审判进行访问。这个问题是从视频17/48。
谢谢,如果您需要更多信息,请让我知道。
感谢您的回复。不幸的是,这并不能解决我所面临的主要问题。我添加了更多的错误日志,以便查看问题来自哪里。我很抱歉不尽快这样做。 这个问题,我相信,是行**提高HTTPNotFound()**被称为 –