Yes, you can make it work correctly.   Just Always include the trailing slash!

That's the way URL's work, the trailing slash has meaning, and that
meaning is respected by the URL rewriter in tg2, where it was not in
tg1.

admin/ gives you the index of the admin resource
admin gives you the admin resource one level up

TG2's dispatcher isn't hardcore about this distinction and still
provides you with a resource, even when you don't include the trailing
slash that you should have.   This is to provide some backwards
compatability and because Apache automatically redirects you from
admin to admin/when you are doing a get request.   But perhaps we
should really be doing a redirect in tg2 rather than just serving up
the resource even when it wasn't exactly called for, but it can result
in an unexpected redirect.  And we can't do a redirect with POSTs at
all, so there would be different behavior on http GET and http POST
requests.

So, there are lots of trade-offs here.

But if you just use the / properly things just work.




On Thu, Mar 19, 2009 at 5:04 AM, Julian Yap <[email protected]> wrote:
>
> I found issues like this as well and read the same thing.  Absolute
> links feel very unpythonic/un-unixy and it's definitely bad practice.
>
> From what I understand it's a problem with the balance of maintaining
> backwards compatibility and the new WSGI environment.
>
> Hopefully it can be fixed in TG2. :P
>
> - Julian
>
> On Mar 15, 10:34 am, Ben Sizer <[email protected]> wrote:
>> I have an 'admin' subcontroller off my root controller. This has an
>> 'index' controller. The HTML for the index contains several relative
>> links to other methods on the admin controller.
>>
>> Usually this page will be reached viahttp://localhost/admin/.
>> Unfortunately it can also be reached byhttp://localhost/admin(no
>> trailing slash) which means relative links break with the browser
>> trying to find them off the root. This can be fixed by using the
>> with_trailing_slash decorator, which appends the trailing slash,
>> meaning /admin redirects to /admin/. All well and good.
>>
>> But now you get the other problem - although /admin/ works, /admin/
>> index now redirects to /admin/index/, meaning all the relative links
>> now look for a non-existent 'index' controller.
>>
>> Ideally I'd like to find a way to serve up the admin index page so
>> that it will always appear at the same level in the URL hierarchy. I
>> don't want it to be possible to display that (or indeed any other)
>> controller in more than one level of the URL hierarchy. Is this
>> possible?
>>
>> I would prefer not to have to change everything to using absolute
>> URLs. There's a hint 
>> athttp://www.turbogears.org/2.0/docs/main/Controllers.html#subcontrolle...
>> that absolute URLs are preferred, but that is a shame as relative URLs
>> are typically shorter and easier to maintain.
>>
>> --
>> Ben Sizer
> >
>



-- 
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to