Update the storage backend (i.e., save the messages). Raise ValueError if not all messages could be stored and DEBUG is True.
(self, request, response)
| 12 | request._messages = default_storage(request) |
| 13 | |
| 14 | def process_response(self, request, response): |
| 15 | """ |
| 16 | Update the storage backend (i.e., save the messages). |
| 17 | |
| 18 | Raise ValueError if not all messages could be stored and DEBUG is True. |
| 19 | """ |
| 20 | # A higher middleware layer may return a request which does not contain |
| 21 | # messages storage, so make no assumption that it will be there. |
| 22 | if hasattr(request, "_messages"): |
| 23 | unstored_messages = request._messages.update(response) |
| 24 | if unstored_messages and settings.DEBUG: |
| 25 | raise ValueError("Not all temporary messages could be stored.") |
| 26 | return response |