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

Opened 11 years ago

Last modified 10 years ago

tg_format=json backwards compatibility

Reported by: nbm Owned by: anonymous
Priority: low Milestone: 2.0b3
Component: TurboGears Version: trunk
Severity: minor Keywords:
Cc:

Description

With TG 1, you could use "tg_format=json" in your request and get JSON back. A friend of mine trying out TG 2 wondered why this no longer worked. Attached is a patch to add support for that back.

Also, the code that handles the mime type detection throws an exception if an invalid mime type is specified in tg_format. That seems drastic - the patch also make specifying an invalid mime type in tg_format fall back to using the accept header, and then logs it at warning level.

Adds a test for the tg_format=json alias.

Attachments

tg-backcompatjson-graceful-format-handling.patch Download (2.0 KB) - added by nbm 11 years ago.

Change History

Changed 11 years ago by nbm

comment:1 Changed 11 years ago by mramm

We should support this, but the right thing to do is to add support for lots of mime types via .type extensions.

So you could tell the server you wanted json from the index page by going to:

http://mysuperapp.org/index.json

or HTML with

http://mysuperapp.org/index.html

or text/javascript with http://mysuperapp.org/index.js

And if there's a handler for the associated content type that should be added.

This patch should probably be applied as is, but it's not the long term solution for TG2.

comment:2 Changed 11 years ago by mramm

  • Milestone changed from 1.9.7a4 to 2.0

I'm not actually sure that we want to support his parameter, since it's kind of an ugly hack and makes your URLS look tg specific which is not that cool.

comment:3 Changed 11 years ago by jorge.vargas

-1 on adding tg_format back. We should implement it as #1473 and document the change.

comment:4 Changed 10 years ago by percious

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

This is now supported, but is deprecated pending removal in 2.1.

comment:5 Changed 10 years ago by mramm

  • Milestone changed from 2.0 to 2.0b3
Note: See TracTickets for help on using tickets.