apart that JSON mimetype is: application/json
(http://www.ietf.org/rfc/rfc4627.txt)
Anyway, this is a nice trick.
2008/3/2 Ben Hoyt <[EMAIL PROTECTED]>:
> Another way is on the __init__ method of the request class, which gets
> called by web.py when the class is instantiated. This way you can do things
> based on the request class type. For instance, I often use classes Html and
> Text, like so:
>
> class Request:
> # base request class, set content_type in sub-class
> def __init__(self):
> web.header('Content-Type', self.content_type)
>
> class Html(Request):
> content_type = 'text/html'
>
> class Text(Request):
> content_type = 'text/plain'
>
> class home(Html):
> def GET(self):
> print '<b>This will be an HTML request</b>.'
>
> class json(Text):
> def GET(self):
> print '["This will be a JSON one."]'
>
> -Ben
>
> 2008/3/3 slav0nic <[EMAIL PROTECTED]>:
>
> >
> > def setheader():
> > web.header("Content-Type","text/html; charset=utf-8")
> >
> > web.loadhooks['setheader'] = setheader
> >
> >
> >
> >
> > On 1 мар, 18:46, Alex Greif <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > > I just started to use webpy and have the following
> > > question:
> > > my requests are forwarded to the webpy app
> > > from an apache through the mod_wsgi. I realize that the
> > > response header (content-type) is not set
> > > automatically. So I have to set in every GET method the
> > > header with web.header(). Is there a way to define the
> > > header contents in one global place or do I have to set
> > > it in every GET methods?
> > >
> > > Thanks,
> > > Alex.
> >
> >
>
>
>
> --
> Ben Hoyt, http://benhoyt.com/
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---