Lostsoul
Lostsoul

Reputation: 26057

Pyramid errors on pages that are not being rendered

i'm getting a really weird error. Somehow no matter what page I'm on it, it loads the page I want then tries to load another page(but since I'm not planning to go to that page the variables its looking for aren't present so it is giving me errors in the console)

Here's my route:

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

if I go to the editdata page, the page loads fine but in my debug screen I get errors related to the profile page(I know I'm in that section because I put print statements outputing what function I'm in and the errrors are related to sql from that page which are not related to the edit page).

I have changed the order of the routes and still get the error, I use some variables named profile in certain functions so I even tried to change the route name to profile1 but I still get the errors. When I comment out the profile route(in init and views) then the error is gone, but obviously my profile area is not accessible.

Any suggestions on what I can try to troubleshoot this? I don't see any references to my profile view other than the in the route(no pages redirect to the profile but on every page in jinja2 I have a link to the profile but I have links to other pages also and don't get errors).

if it helps here's the traceback(all I did was go to the viewdata page and didn't go to the profile page at all).:

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'

you can see(near the top) it renders the viewdata view successfully(outputting the variables and telling me that's where I am) but then for some reason it loads the profile page as well. I'm confused to why it does this and where that request to load it is coming from.

Upvotes: 2

Views: 579

Answers (1)

Michael Merickel
Michael Merickel

Reputation: 23331

If you look near the top of your paste you can see that the URL that is generating the error is '/favicon.ico' which the browser requests whenever you visit your site. That path matches the regex for your profile url '/{userurl}'.

Upvotes: 3

Related Questions