Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 未呈现页面上的金字塔错误_Python_Pyramid - Fatal编程技术网

Python 未呈现页面上的金字塔错误

Python 未呈现页面上的金字塔错误,python,pyramid,Python,Pyramid,我犯了一个很奇怪的错误。不知何故,无论我在哪个页面上,它都会加载我想要的页面,然后尝试加载另一个页面(但由于我不打算转到该页面,因此它寻找的变量不存在,因此在控制台中会给我错误) 这是我的路线: config.add_route('editdata', '/{userurl}/{dataname}/edit') config.add_route('viewdata', '/{userurl}/{dataname}') config.add_route('profile', '/{userurl}

我犯了一个很奇怪的错误。不知何故,无论我在哪个页面上,它都会加载我想要的页面,然后尝试加载另一个页面(但由于我不打算转到该页面,因此它寻找的变量不存在,因此在控制台中会给我错误)

这是我的路线:

config.add_route('editdata', '/{userurl}/{dataname}/edit')
config.add_route('viewdata', '/{userurl}/{dataname}')
config.add_route('profile', '/{userurl}')
如果我转到editdata页面,页面加载正常,但在调试屏幕中,我会收到与配置文件页面相关的错误(我知道我在该部分,因为我放置了输出我所处函数的打印语句,错误与该页面中与编辑页面无关的sql相关)

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

有什么建议我可以尝试解决这个问题吗?除了路由中的外,我看不到任何对我的配置文件视图的引用(没有页面重定向到配置文件,但在jinja2的每个页面上,我都有一个到配置文件的链接,但我也有到其他页面的链接,并且没有错误)

如果有帮助,这里是回溯(我所做的只是转到viewdata页面,而根本没有转到profile页面)


您可以看到(靠近顶部)它成功地呈现了viewdata视图(输出变量并告诉我我在哪里),但出于某种原因,它也加载了profile页面。我不明白它为什么会这样做,以及加载它的请求来自何处。

如果您查看粘贴顶部附近的内容,您可以看到生成错误的URL是
'/favicon.ico'
,每当您访问您的站点时,浏览器都会请求该URL。该路径与您的配置文件url的正则表达式
'/{userurl}

匹配。如果您查看粘贴顶部附近的内容,您可以看到生成错误的url是
'/favicon.ico'
,每当您访问站点时,浏览器都会请求该url。该路径与您的个人资料url
'/{userurl}'
的正则表达式匹配。
谢谢Michael。.我仍在努力解决这个问题。我做了一些搜索,在我的静态文件夹中找到了favicon.ico,它是一个金字塔图标(不确定,但认为它是网站图标脚手架附带的图标)。我在我的模板、视图和init文件中搜索了它,但找不到任何对它的引用。金字塔中是否还有其他地方可以引用它?顺便说一句,我想它带有.pt,但我切换了,正在使用jinja2。好的,我有点停止了错误。我在主模板中添加了标题,错误似乎消失了。我猜如果您没有该文件,它会在域的根目录中查找它。谢谢你,迈克尔!如果您没有指定另一个favicon,浏览器将始终从站点的根目录请求favicon。这是一个浏览器皱纹,与你的金字塔应用程序无关。在测试特定url时,使用curl可以避免此类副作用。谢谢Michael,我会的。我不知道浏览器触发了它,这很有趣。再次感谢。谢谢迈克尔。我还在努力解决这个问题。我做了一些搜索,在我的静态文件夹中找到了favicon.ico,它是一个金字塔图标(不确定,但认为它是网站图标脚手架附带的图标)。我在我的模板、视图和init文件中搜索了它,但找不到任何对它的引用。金字塔中是否还有其他地方可以引用它?顺便说一句,我想它带有.pt,但我切换了,正在使用jinja2。好的,我有点停止了错误。我在主模板中添加了标题,错误似乎消失了。我猜如果您没有该文件,它会在域的根目录中查找它。谢谢你,迈克尔!如果您没有指定另一个favicon,浏览器将始终从站点的根目录请求favicon。这是一个浏览器皱纹,与你的金字塔应用程序无关。在测试特定url时,使用curl可以避免此类副作用。谢谢Michael,我会的。我不知道浏览器触发了它,这很有趣。再次感谢。我建议您安装并使用Firebug(或使用Chrome开发者工具)-这将允许您查看浏览器向您的应用发送的确切请求,这将使调试此类问题变得更加容易。我建议您安装并使用Firebug(或使用Chrome开发者工具)-这将允许您查看哪些请求是通过浏览器发送到您的应用程序的,这将使调试此类问题更加容易
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'