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 #2322 (closed task: fixed)

Opened 10 years ago

Last modified 9 years ago

Optionally Turn Off Request Extensions

Reported by: asabil Owned by: percious
Priority: high Milestone: 2.1b1
Component: TurboGears Version: 2.0rc1
Severity: normal Keywords:

Description (last modified by jorge.vargas) (diff)

Today I have been bitten by a rather unexpected behaviour from Turbogears 2 with the following code:

class UserController(BaseController):
   def default(self, user, **kwargs):
       print user
       return dict()

This controller works like a charm for this request: /user/ali.sabil But produces a rather confusing result for /user/john.man

The problem comes from the fact that .man is a known filename extension for a known mimetype, which leads the TG2 ObjectDispatchController? to chop the extension off, and have user=john in the controller.

I understand that this behaviour can be very useful in many scenarios, but I think TG2 should provide a simple way to disable it completely.

That is a totally unexpected side effect.

I think we should upgrade the internal code to only serve the mimetypes from a restricted list. Instead of depeding on the mimetypes module which does some weird stuff.

At this point that is a bug that can't be turned off as it assumes foo.something is a call to the mimetypes system. I guess we could add a flag to turn it off.

Change History

comment:1 Changed 10 years ago by jorge.vargas

  • Type changed from defect to task
  • Description modified (diff)
  • Summary changed from Mimetypes side effect to Optionally Turn Off Request Extensions


comment:2 Changed 10 years ago by jorge.vargas

  • Priority changed from normal to high
  • Owner set to percious

After looking at this. I think that the problem is that TG is not respecting it's configuration. In tg/configuration.py the "lookup" is not stored anywhere therefore in tg/controllers/dispatcher.py TG is simply asking the mimetypes module to pull the data without respecting the config, the fix seems simple, Store this lookup in the config and add an additional check to the dispatcher. But I'll like Chris to confirm.

comment:3 Changed 10 years ago by jorge.vargas

  • Milestone set to 2.1

comment:4 Changed 10 years ago by percious

  • Status changed from new to assigned
  • Milestone changed from 2.1 to 2.1b1

comment:5 Changed 9 years ago by percious

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

comment:6 Changed 9 years ago by percious

Added a disable_request_extensions flag to the config

Note: See TracTickets for help on using tickets.