Hi -

On Sep 23, 2009, at 1:36, Qiangning Hong <[email protected]> wrote:

>
> On Wed, Sep 23, 2009 at 1:17 PM, Mike Orr <[email protected]>  
> wrote:
>>
>> On Tue, Sep 22, 2009 at 8:06 PM, Jonathan Vanasco <[email protected] 
>> > wrote:
>>>
>>> by default it sets response.content_type to "application/json"
>>>
>>> is there a way to override this?
>>> if not , could I request this in a future version of pylons ?
>>>
>>> though testing, i discovered that a lot of browsers will 'download'
>>> application/json files if you hit them directly -- ie, they won't
>>> render in the browser, they'll just save to disk.
>>>
>>> the same browsers will render "text/javascript" files fine.
>>>
>>> i've got some custom code that lets me dev stuff, but something  
>>> built
>>> into pylons would probably be useful for others.
>>
>> I don't quite grok decorators, but it looks like it would have to  
>> be a
>> separate function.  The signature is jsonify(func, *args, **kw), so
>> there's no place to add a content-type argument.
>
> I'd like to make jsonify more smart:  use pylons.config['debug'] to
> decide to serve as application/json or text/javascript.  i.e.
> text/javascript only under debug environment for easier debugging,
> otherwise the more standard application/json.
>
>> Also, is it proper to send JSON as text/javascript? Would this be
>> widely enough used? What is the purpose, to display it in the  
>> browser?
>
> As what http://www.iana.org/assignments/media-types/text/ describes,
> text/javascript is obsolete, use application/javascript instead for
> .js files.  And application/json is the standard media type for JSON
> data ( ref: http://www.ietf.org/rfc/rfc4627.txt )

Actually, for some browsers, json-rpc reqs simply will not work unless  
the content type is something more "texty".  In these cases, it is not  
a question of making it easier to debug (if anything, I think you'd  
want it to be wrong for production).  We even found one case (ie6?)  
that required content type of text/html or it would puke. Sorry that I  
don't remember the offenders offhand; I'm sure IE6 is on that list,  
but I think maybe older FF and maybe older Safari too?

Hans

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to