changed way of getting request object

Before *request* was *self.request*.
Now it is passed as a function parameter.