Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1904 (closed defect: fixed)

Opened 11 years ago

Last modified 9 years ago

Handle lack of trailing slash issues better

Reported by: mramm Owned by: percious
Priority: high Milestone: 2.0b5
Component: TurboGears Version: trunk
Severity: normal Keywords: sprint
Cc:

Description

We can do a redirect on http-get requests, and throw an error on http-post.

Attachments

LookupSample.zip Download (165.1 KB) - added by amcgregor 11 years ago.
Run the sample and visit http://localhost:8080/about and http://localhost:8080/about/ -- watch the logs.

Change History

comment:1 Changed 11 years ago by mramm

The current behavior is strict by default, so loosining it up in beta1 should be ok. So, I'm moving this out to beta1.

comment:2 Changed 11 years ago by amcgregor

Additionally, I have the following problem: accessing a controller (not a method) at the following URL paths give different results.

/about
/about/

The first, without a trailing slash, calls the index method directly, which is correct.

The second, with a trailing slash, calls my lookup method with an empty string first argument, ignoring my index method.

I believe the standard behavior should be to call the index method if there are no further path elements. A slash by itself isn't, in my books, classified as a valid path element.

Temporarily, I'll simply put a conditional in my lookup method to handle an empty argument.

A sample log file from my application (as seen on IRC):

 http://pastie.textmate.org/private/xjwepsdl39mueuhotyq

I will attach a fresh quickstarted application which demonstrates the issue.

Changed 11 years ago by amcgregor

Run the sample and visit http://localhost:8080/about and http://localhost:8080/about/ -- watch the logs.

comment:3 Changed 11 years ago by amcgregor

Quick additional note: visiting the site root (which has a trailing slash) calls index directly, which differs from the standard trailing slash bug.

comment:4 Changed 11 years ago by amcgregor

Simple work-around monkeypatch on a per-controller basis; add the following to the top of your lookup method:

if node is u"":
    return self, ["index"]

comment:5 Changed 11 years ago by mramm

  • Priority changed from normal to high
  • Milestone changed from 1.9.7a4 to 1.9.7b2

comment:6 Changed 10 years ago by mramm

  • Milestone changed from 1.9.7b2 to 2.0b1

comment:7 Changed 10 years ago by mramm

  • Keywords sprint added

comment:8 Changed 10 years ago by mramm

  • Milestone changed from 2.0b1 to 2.0

comment:9 Changed 10 years ago by percious

Another per-controller method way of handling this is:

        if not pylons.request.url.endswith('/'):
            redirect(pylons.request.url+'/')

comment:10 Changed 10 years ago by mramm

  • Milestone changed from 2.0 to 2.0b4

comment:11 Changed 10 years ago by percious

  • Owner changed from anonymous to percious

I believe this is addressed in r6098. We just need to add some documentation about how to use them. The docstrings are pretty weak.

comment:12 Changed 10 years ago by percious

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.