How to resolve the add_route URLs conflict

20 views
Skip to first unread message

lxneng

unread,
Sep 21, 2016, 11:56:15 AM9/21/16
to pylons-discuss

Hi,


after upgrade to pyramid 1.7.3, these route will conflict:

# photos
config.add_route('photos', '/photos')
config.add_route('all_photos', '/photos/all')
config.add_route('all_photos_pagination', '/photos/all/{page:\d+}')
config.add_route('photos_album', '/photos/albums/{id:\d+}',
                 factory=factories.AlbumFactory)
config.add_route('photos_album_new', '/photos/albums/new')
config.add_route('photos_album_edit', '/photos/albums/{id:\d+}/edit',
                 factory=factories.AlbumFactory)
config.add_route(
    'photos_album_upload', '/photos/albums/{id:\d+}/upload',
    factory=factories.AlbumFactory)

open http://localhost:6543/photos/all got 404 resource not found error.

envs:

python = 3.5.1
pyramid = 1.7.3

Michael Merickel

unread,
Sep 21, 2016, 12:45:28 PM9/21/16
to Pylons
There are several reasons you can get a 404. Have you tried enabling notfound debugging[1] or using the pviews command-line to see what you get? You can also enable route match debugging explicitly to see if it's an issue with routes, but likely it's not anything to do with the code you've pasted.


--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/10740ccc-ae03-42ad-959a-f7b4b6c80c1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mikko Ohtamaa

unread,
Sep 21, 2016, 3:41:07 PM9/21/16
to pylons-...@googlegroups.com

open http://localhost:6543/photos/all got 404 resource not found error.


You can also get 404 in the case you have are rendering a template and the template cannot be found on file system.
--

Eric Lo

unread,
Sep 21, 2016, 10:31:15 PM9/21/16
to pylons-...@googlegroups.com
but when i change to `config.add_route('all_photos', '/photos-all’)`, it works.

-- 
Best Regards,
Eric Lo
https://lxneng.com

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvHZLyp5DN%2B%2B%3D8WOFpYq%3DUoiUc8ZEAeXcnhK4EOFpVQXA%40mail.gmail.com.

Eric Lo

unread,
Sep 21, 2016, 10:51:21 PM9/21/16
to pylons-...@googlegroups.com
Thanks Michael and Mikko.

resolved, that conflict by `config.add_static_view('photos_static', settings['photos_dir'], cache_max_age=3600)`



-- 
Best Regards,
Eric Lo
https://lxneng.com

Eric Lo

unread,
Sep 21, 2016, 10:55:17 PM9/21/16
to pylons-...@googlegroups.com
oops.  typo fix:

conflict by `config.add_static_view('photos', settings['photos_dir'], cache_max_age=3600)`

change static view name will resolved,

 `config.add_static_view('photos_static', settings['photos_dir'], cache_max_age=3600)` 

-- 
Best Regards,
Eric Lo
https://lxneng.com

Reply all
Reply to author
Forward
0 new messages