On Apr 2, 2007, at 5:20 PM, Mike Orr wrote:

> This is probably a Pylons problem rather than Routes.  I have a
> routing rule like this:
>
>     map.connect("glossary", "/glossary/:page", controller="main",
>         action="glossary", page="index")
>
> h.url_for("glossary")  generates "/glossary" rather than the expected
> "/glossary/".  When the user clicks on the link, Pylons serves the
> index page directly rather than redirecting to "/glossary/" like
> Apache and other frameworks do.  This breaks any relative links on the
> page because a link to "foo" will resolve to "/foo" instead of
> "/glossary/foo".

That's intentional and required behavior for the concept of minimal  
URL's:
http://routes.groovie.org/manual.html#minimum-urls

Consider the example there, if your page assumes its 2 levels deep,  
but you have defaults, then you can get a URL that even if it had a  
trailing /, wouldn't be in the right directory that you had assumed.  
url_for and Routes has the concept of Route memory to avoid the need  
for relative URL's entirely. Ie, if you're at /content/view/4 and  
need to link to '3', you can just do url_for(id=3). This is assuming  
the example shown at the minimum-url's bit.

If you really want to use relative links, don't provide defaults for  
dynamic parts present in the URL. That's the only real way you can  
guarantee the URL will be in the right directory. Ie, if you change  
your map.connect statement to:

map.connect("glossary", "/glossary/:page", controller="main",  
action="glossary")

Then all your URL's will definitely have the /glossary/ section, and  
the shortest valid URL will be /glossary/index.

> In related news, the URL that Paster serve prints for access is
> "http://127.0.0.1:5000";.  This is an invalid URL even though Pylons
> accept it.  It should be "http://127.0.0.1:5000/";.

I thought a recent Paste fixed this.. Ian?

Cheers,
Ben

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to