Created
May 2, 2013 20:36
-
-
Save marsam/5505214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import http | |
| from django.conf import settings | |
| from django.utils.importlib import import_module | |
| class DummyRequest(http.HttpRequest): | |
| def __init__(self, POST=None): | |
| super(DummyRequest, self).__init__() | |
| self.method = POST and "POST" or "GET" | |
| if POST is not None: | |
| self.POST.update(POST) | |
| self.session = {} | |
| self._dont_enforce_csrf_checks = True | |
| def get_request(*args, **kwargs): | |
| request = DummyRequest(*args, **kwargs) | |
| engine = import_module(settings.SESSION_ENGINE) | |
| request.session = engine.SessionStore(None) | |
| return request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment