Created
May 1, 2011 23:36
-
-
Save sorl/950990 to your computer and use it in GitHub Desktop.
This file contains 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
# management command | |
from django.contrib.staticfiles.management.commands.runserver import Command as StaticFilesCommand | |
from django.contrib.staticfiles.handlers import StaticFilesHandler | |
from nimda.globals import _local_manager | |
class Command(StaticFilesCommand): | |
def get_handler(self, *args, **options): | |
handler = super(Command, self).get_handler(*args, **options) | |
handler = _local_manager.make_middleware(handler) | |
return handler | |
# nimda.globals | |
from werkzeug.local import Local, LocalManager, LocalProxy | |
_local = Local() | |
_local_manager = LocalManager([_local]) | |
request = LocalProxy(_local, 'request') | |
# nimda.middleware | |
from nimda.globals import _local | |
class ThreadLocals(object): | |
def process_request(self, request): | |
_local.request = request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment