diff --git a/falcon/request.py b/falcon/request.py index 30a2bd3..dd49159 100644 --- a/falcon/request.py +++ b/falcon/request.py @@ -243,6 +243,7 @@ class Request(object): 'options', '_cookies', '_cached_access_route', + '__dict__', ) # Child classes may override this diff --git a/falcon/response.py b/falcon/response.py index 44d3d5d..fd25479 100644 --- a/falcon/response.py +++ b/falcon/response.py @@ -116,6 +116,7 @@ class Response(object): 'stream', 'stream_len', 'context', + '__dict__', ) # Child classes may override this diff --git a/tests/test_slots.py b/tests/test_slots.py new file mode 100644 index 0000000..665ea32 --- /dev/null +++ b/tests/test_slots.py @@ -0,0 +1,22 @@ +from falcon import Request, Response +import falcon.testing as testing + + +class TestSlots(testing.TestBase): + + def test_slots_request(self): + env = testing.create_environ() + req = Request(env) + + try: + req.doesnt = 'exist' + except AttributeError: + self.fail('Unable to add additional variables dynamically') + + def test_slots_response(self): + resp = Response() + + try: + resp.doesnt = 'exist' + except AttributeError: + self.fail('Unable to add additional variables dynamically')