我工作過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()**被稱爲 –