gpt4 book ai didi

python - 未呈现页面上的 Pyramid 错误

转载 作者:太空宇宙 更新时间:2023-11-03 15:23:20 25 4
gpt4 key购买 nike

我遇到了一个非常奇怪的错误。不知何故,无论我在哪个页面上,它都会加载我想要的页面,然后尝试加载另一个页面(但由于我不打算去那个页面,它寻找的变量不存在所以它给了我控制台错误)

这是我的路线:

config.add_route('editdata', '/{userurl}/{dataname}/edit')
config.add_route('viewdata', '/{userurl}/{dataname}')
config.add_route('profile', '/{userurl}')

如果我转到 editdata 页面,该页面加载正常,但在我的调试屏幕中,我收到与配置文件页面相关的错误(我知道我在那个部分,因为我放置了打印语句输出我所在的函数,错误与该页面中的 sql 有关,而与编辑页面无关)。

我已经更改了路由的顺序,但仍然出现错误,我在某些函数中使用了一些名为 profile 的变量,所以我什至尝试将路由名称更改为 profile1,但仍然出现错误。当我注释掉配置文件路由(在 init 和 View 中)时,错误消失了,但显然我的配置文件区域不可访问。

关于我可以尝试解决此问题的任何建议?除了在路由中,我没有看到任何对我的个人资料 View 的引用(没有页面重定向到个人资料,但在 jinja2 的每个页面上我都有一个到个人资料的链接,但我也有到其他页面的链接并且没有得到错误)。

如果它有帮助,这里是回溯(我所做的只是转到 View 数据页面,根本没有转到配置文件页面)。:

C:\Users\lostsoul\Desktop>C:\Users\lostsoul\GoogleDrive\pyramidtut\Scripts\pserve.
exe C:\Users\lostsoul\GoogleDrive\pyramidtut\tutorial\development.ini --reload
Starting subprocess with file monitor
Starting server in PID 4016.
serving on http://0.0.0.0:6543
we are viewing the data
****
Variables are:
monkey
dog
*****
we are in profile section
2012-07-19 00:07:01,388 ERROR [pyramid_debugtoolbar][Dummy-2] Exception at http:
//localhost:6543/favicon.ico
traceback url: http://localhost:6543/_debug_toolbar/exception?token=c0660cf901de
bc8c3af7&tb=67564912
Traceback (most recent call last):
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid_debugt
oolbar-1.0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py", line 122, in toolbar_tw
een
response = _handler(request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid_debugt
oolbar-1.0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py", line 69, in
noresource_timer_handler
result = handler(request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\tweens.py", line 20, in excview_tween
response = handler(request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid_tm-0.5
-py2.7.egg\pyramid_tm\__init__.py", line 100, in tm_tween
response = handler(request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\router.py", line 164, in handle_request
response = view_callable(context, request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\config\views.py", line 333, in rendered_view
result = view(context, request)
File "C:\Users\lostsoul\GoogleDrive\pyramidtut\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\config\views.py", line 471, in _requestonly_view
response = view(request)
File "c:\users\lostsoul\googledrive\pyramidtut\tutorial\tutorial\views.py", lin
e 109, in profile
profile_info = DBSession.query(data).filter(data.owner==profileda
ta.id).all()
AttributeError: 'NoneType' object has no attribute 'id'

你可以看到(靠近顶部)它成功地呈现了 viewdata View (输出变量并告诉我那是我所在的位置)但是由于某种原因它也加载了配置文件页面。我对它为什么这样做以及加载它的请求来自何处感到困惑。

最佳答案

如果您查看粘贴顶部附近,您会发现生成错误的 URL 是 '/favicon.ico',每当您访问您的站点时浏览器都会请求它。该路径匹配您个人资料 url '/{userurl}' 的正则表达式。

关于python - 未呈现页面上的 Pyramid 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11553840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com