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

Contents of /trunk/harmonious/_response.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download) (as text)
Thu Jun 16 00:41:45 2005 UTC (9 years ago) by port001
File MIME type: text/x-python
File size: 1194 byte(s)
Convert Header to Id
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
20 def set_encoding(self, encoding):
21
22 self._encoding = encoding
23
24 def get_encoding(self):
25
26 return self._encoding
27
28 def reset(self):
29
30 self.__init__()
31
32 def add_responder(self, responder):
33
34 if type(responder) != InstanceType:
35
36 raise TypeError('Paramter is not of instance type')
37
38 if hasattr(responder, '_construct'):
39
40 responder._construct()
41 headers = responder.get_headers()
42
43 for key in headers.keys():
44
45 if not self._headers.has_key(key):
46
47 self._headers[key] = headers[key]
48
49 if responder.get_body() != '':
50
51 self.append_body(responder.get_body())
52 else:
53
54 raise ProgrammingError('Malformed responder class: \'_construct\' method undefined')

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20