Hi bubblboy,
would it be possible, that you post a small sample with the decorators?
Then this thread would contailn some good samples how to do it.
thanks,
Alex.
--
[EMAIL PROTECTED]
On 02.03.2008, at 20:12, bubblboy wrote:
>
> Ben Hoyt wrote:
>> 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] <mailto:[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]
>> <mailto:[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/
>
> That one is nice :) I personally use decorators, it's a little more
> work
> but it does the job as well ^^
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---