comparison MoinMoin/web/request.py @ 5582:ca98db50efac

request: fix for werkzeug 0.6 and 0.5.1 compatibility
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 25 Feb 2010 01:35:06 +0100
parents 3a79d3ca5a83
children a8199daaf217
comparison
equal deleted inserted replaced
5580:af56baebf4d1 5582:ca98db50efac
45 self.abs_href = Href(self.url_root, self.charset) 45 self.abs_href = Href(self.url_root, self.charset)
46 self.headers = Headers([('Content-Type', 'text/html')]) 46 self.headers = Headers([('Content-Type', 'text/html')])
47 self.response = [] 47 self.response = []
48 self.status_code = 200 48 self.status_code = 200
49 49
50 in_stream = RequestBase.stream 50 # XXX ugly hack begin - works by sheer luck
51 # TODO keep request and response separate, don't mix them together
52 stream = property() # protect inherited .stream attr from accessing
53
54 try:
55 # for werkzeug 0.6
56 in_stream = cached_property(RequestBase.stream.func, 'in_stream')
57 except AttributeError:
58 # no .func -> werkzeug 0.5
59 in_stream = RequestBase.stream
60
61 try:
62 # for werkzeug 0.6
63 out_stream = cached_property(ResponseBase.stream.func, 'out_stream')
64 except AttributeError:
65 # no .func -> werkzeug 0.5
66 out_stream = ResponseBase.stream
67 # XXX ugly hack end
51 68
52 @cached_property 69 @cached_property
53 def in_data(self): 70 def in_data(self):
54 return self.in_stream.read() 71 return self.in_stream.read()
55 72