On 12:48 pm, peter.westlake@pobox.com wrote:
On Tue, 28 Sep 2010 17:52 +0000, exarkun@twistedmatrix.com wrote: ...
It's correct that setHeader and getHeader operate on different data sets. Less confusing names for what the two methods do would have been setResponseHeader and getRequestHeader respectively.
In newer versions of Twisted, the requests have two new attributes, requestHeaders and responseHeaders, with various methods for inspection and modification. Nevow's Request class should inherit these. However Nevow's FakeRequest probably doesn't.
The right way to test for headers is probably to fix the FakeRequest class so that it is more inspectable, and to verify that it actually behaves in the same way as a real request object.
Thanks for the explanation! I've done this for now:
class FakeRequest(nevow.testutil.FakeRequest): def getResponseHeader(self, key): return self.headers.get(key.lower())
Should I put in a ticket requesting something like this?
Certainly. Things are a little mixed up here though, let's see... Twisted Web provides a base Request class. Nevow subclasses it to create the request class all Nevow applications get. Then Twisted Web also provides a FakeRequest, which isn't very good, and I think there is a ticket (in the Twisted tracker) for improving. Then Nevow provides its own FakeRequest, not a subclass of Twisted's FakeRequest. There probably needs to be a Nevow ticket for doing something about Nevow's FakeRequest class - in the short term, fixing these minor issues; but in the longer term, getting rid of it, and hopefully NevowRequest as well, makes a lot of sense. Jean-Paul