So basically, I want a middleware to connect a signal listener that adds stuff to the request object. This information can then be included in a response. I currently have this:
class SomeMiddleware:
def process_request(self, request):
request.signals_received = ["I can see this"]
def listener(sender, **kwargs):
print "I can see this too"
request.signals_received.append("I can't see this")
some_signal.connect(listener)
def process_response(self, request, response):
response.write(request.signals_received)
return response
The problem is, I can't see stuff I append in the listener. What up with that?
Ultimately, the listener should register parallel tasks which may or may not be done in time to add them to the response just before rendering.
edit - quotes in snippet