pyramid - How to handle complex URL in a elegant way?
Posted
by
Lingfeng Xiong
on Stack Overflow
See other posts from Stack Overflow
or by Lingfeng Xiong
Published on 2012-11-02T10:29:32Z
Indexed on
2012/11/02
11:00 UTC
Read the original article
Hit count: 219
pyramid
I'm writing a admin website which control several websites with same program and database schema but different content. The URL I designed like this:
http://example.com/site A list of all sites which under control
http://example.com/site/{id} A brief overview of select site with ID id
http://example.com/site/{id}/user User list of target site
http://example.com/site/{id}/item A list of items sold on target site
http://example.com/site/{id}/item/{iid} Item detailed information
# ...... something similar
As you can see, nearly all URL are need the site_id. And in almost all views, I have to do some common jobs like query Site model against database with the site_id. Also, I have to pass site_id whenever I invoke request.route_path.
So... is there anyway for me to make my life easier?
Thanks in advance.
© Stack Overflow or respective owner