-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathResponse.py
More file actions
77 lines (48 loc) · 1.7 KB
/
Response.py
File metadata and controls
77 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""An abstract response"""
from time import time
from MiscUtils import AbstractError
class Response:
"""The abstract response class.
Response is a base class that offers the following:
* A time stamp (indicating when the response was finished)
* An output stream
Response is an abstract class; developers typically use HTTPResponse.
"""
# region Init
def __init__(self, trans, strmOut):
self._strmOut = strmOut
self._transaction = trans
# endregion Init
# region End time
def endTime(self):
return self._endTime
def recordEndTime(self):
"""Record the end time of the response.
Stores the current time as the end time of the response. This should
be invoked at the end of deliver(). It may also be invoked by the
application for those responses that never deliver due to an error.
"""
self._endTime = time()
# endregion End time
# region Output
def write(self, output):
raise AbstractError(self.__class__)
def isCommitted(self):
raise AbstractError(self.__class__)
def deliver(self):
raise AbstractError(self.__class__)
def reset(self):
raise AbstractError(self.__class__)
def streamOut(self):
return self._strmOut
# endregion Output
# region Cleanup
def clearTransaction(self):
del self._transaction
# endregion Cleanup
# region Exception reports
_exceptionReportAttrNames = ['endTime']
def writeExceptionReport(self, handler):
handler.writeTitle(self.__class__.__name__)
handler.writeAttrs(self, self._exceptionReportAttrNames)
# endregion Exception reports