I am using this code to run django within twisted.
from django.core.handlers.wsgi import WSGIHandler
def wsgi_resource():
pool = threadpool.ThreadPool()
pool.start()
# Allow Ctrl-C to get you out cleanly:
reactor.addSystemEventTrigger('after', 'shutdown', pool.stop)
real_wsgi_app = WSGIHandler()
def my_wsgi_wrapper(environ, start_response):
environ['somekey'] = "somevalue"
return real_wsgi_app(environ, start_response)
wsgi_resource = wsgi.WSGIResource(reactor, pool, my_wsgi_wrapper)
return wsgi_resource
wsgi_root = wsgi_resource()
reactor.listenTCP(DJANGO_PORT, server.Site(wsgi_root))
in my django views, how do I access the key "somekey"? I hope to pass in an instance of a particular class which I wrote.