/[glsr]/trunk/harmonious/_response.py
Gentoo

Contents of /trunk/harmonious/_response.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (show annotations) (download) (as text)
Sun Jul 3 09:32:05 2005 UTC (9 years, 2 months ago) by port001
File MIME type: text/x-python
File size: 1089 byte(s)
Allow the HTTP response to be changed via harm.response.status

1 __id__ = '$Id$'
2 __version__ = '$Revision: $'
3 __modulename__ = 'Response'
4
5 from types import InstanceType
6
7 from harmonious._baseresponse import BaseResponse
8
9 class TypeError(Exception): pass
10 class ProgrammingError(Exception): pass
11
12 class Response(BaseResponse):
13
14 def init(self):
15
16 self.headers = {}
17 self.body = ''
18 self.encoding = 'utf-8'
19 self.session = None
20 self.status = 0
21
22 def reset(self):
23
24 self.__init__()
25
26 def add_responder(self, responder):
27
28 if type(responder) != InstanceType:
29
30 raise TypeError('Paramter is not of instance type')
31
32 if hasattr(responder, '_construct'):
33
34 responder._construct()
35 headers = responder.headers
36
37 for key in headers.keys():
38
39 if not self.headers.has_key(key):
40
41 self.headers[key] = headers[key]
42
43 if responder.body != '':
44
45 self.append_body(responder.body)
46 else:
47
48 raise ProgrammingError('Malformed responder class: \'_construct\' method undefined')

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20