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 #2291 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Missing index method raises unrecoverable 404 instead of calling the lookup method.

Reported by: amcgregor Owned by:
Priority: normal Milestone:
Component: TurboGears Version: 2.0
Severity: major Keywords:
Cc:

Description

Howdy!

Previous Behavior

As of b2, I am able to omit the index method from a controller and have the tree parser automatically call the lookup method with one of (an empty string) or 'index' depending on the presence of a trailing slash. (The trailing slash issue was filed under a separate ticket some time ago.)

Current Behavior

Omitting the index method and attempting to request a URL that would trigger it results in an unrecoverable 404 error.

Notes

My CMF's lookup method was already getting way past gnarly and now it seems I'll have to hack in a dummy index method, too.

Steps to Reproduce

Use this as the root.py controller in a new quickstart application:

# -*- coding: utf-8 -*-

from tg import expose, flash, require, url, request, redirect

from ugtest.lib.base import BaseController
from ugtest.controllers.error import ErrorController

__all__ = ['RootController']


class SampleController(BaseController):
    def __init__(self, name):
        self.__name = name
        super(SampleController, self).__init__()
    
    @expose()
    def index(self):
        return "Should never get here."
    
    @expose()
    def whatsMyName(self):
        return self.__name


class RootController(BaseController):
    error = ErrorController()
    
    @expose()
    def thisWorks(self):
        return "This works."
    
    @expose()
    def lookup(self, node='shouldBeIndex', *remainder):
        return SampleController(node), ['whatsMyName']

Use the following URLs to test:

http://localhost:8080/ -- Expected output: "index" -- Actual output: 404 error.
http://localhost:8080/helloWorld/ -- Correct output.
http://localhost:8080/thisWorks -- Correct output.

Change History

comment:1 Changed 10 years ago by amcgregor

Quick update to note additional versions which I can confirm as working: 2.0b3 and r6101.

comment:2 Changed 10 years ago by Chris Arndt

  • Version changed from trunk to 2.0

comment:3 Changed 10 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to fixed

This is currently working with tgtip.

Note: See TracTickets for help on using tickets.