On Sun, Jun 21, 2009 at 2:26 PM, Boyd<[email protected]> wrote: > > That's great news; I've just spent the evening fighting a content_type > issue ;) > >> - content_type support improved (now it's not ugly) > > But I now have an issue of text/plain taking precedence over text/html > with IE7 on a RestController, the method is defined with different > possible content-type as shown below: > > @expose('vcrm.templates.rest_get_all') > @expose(content_type='text/csv') > @expose(content_type='text/plain') > @expose('json') > def get_all(self, **kw): > """ over simplified architecture of the function: > client_request_xxx are only sniffing the content-type of the request/ > response """ > if client_request_json(): > return dict(a=b) > elif client_request_csv(): > return "a,b,c" > elif client_request_text(): > return "blabla" > return dict() > > With the decorator @expose(content_type='text/plain') IE7 receives a > text/plain page. Chrome 2, Firefox 3.5 and opera 10b receive the more > interesting text/html version. Without the text/plain decorator it > works as expected (or more precisely as I understand it). > I believe this is currently not supported. in fact the "new" syntax is simply syntax-sugar under the hood it is doing the pylons.response....
I believe the current implementation will overwrite the content_type with the last you specified. if you need to modify the content_type based on a if/else construction you still need to use the old syntax. Of course a patch to make it work on a stacking basis will be great but I'm not sure if that's doable giving that there is no way to figure out which one you are actually using. > So either I misunderstood something which is most likely or there is a > bug in the way this update handle IE's Accept header */* in that > particular case. > This is indeed seems like a bug in IE. If I recall correctly if you return a str IE will think it's plain/text and firefox/gecko will think it's test/html > I've just tried upgrading my env by running the command found in the > doc (tg2env)$ easy_install -U -i > http://www.turbogears.org/2.0/downloads/current/index > tg.devtools) I don't know if I missed another step. > that is correct. Just to be sure search for the 2.0.1 egg :) > Any help will be appreciated. > Boyd > > > The header of the request are as follow: > > --------- IE7 -------------- > > GET /partner/ HTTP/1.1 > Accept: */* > Accept-Language: en-us > UA-CPU: x86 > Accept-Encoding: gzip, deflate > User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; > SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR > 1.1.4322; Tablet PC 2.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618) > Host: 127.0.0.1:8080 > Connection: Keep-Alive > Pragma: no-cache > Cookie: > vcrm=6c6a0cf163013e302f955773aeb0a5d47f69e747684682aab50d3ce17ee8a0216e5c2af7; > authtkt=223f411f320027133a1935922902f5214a3e702cadmin! > > > HTTP/1.0 200 OK > Server: PasteWSGIServer/0.5 Python/2.6.1 > Date: Sun, 21 Jun 2009 18:09:20 GMT > Pragma: no-cache > Cache-Control: no-cache > Content-Type: text/plain; charset=utf-8 > Connection: close > > ----- FIREFOX ----------- > GET /partner HTTP/1.1 > Host: localhost:8080 > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1) > Gecko/20090616 Firefox/3.5 (.NET CLR 3.5.30729) > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ > *;q=0.8 > Accept-Language: en-us,en;q=0.5 > Accept-Encoding: gzip,deflate > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 > Keep-Alive: 300 > Connection: keep-alive > Cookie: > vcrm=680d4286fa7bf88498174a661cf41e0e6a7ec830431e669438b937e9e7ca97b86b360047; > authtkt=9fd2e9e590c6c13a89d213c23978fc634a3e3f0aadmin! > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

