On Tue, May 17, 2011 at 11:01 AM, Jannis Leidel <lei...@gmail.com> wrote: >> I was looking more for transaction rollback semantics -- rather than >> overriding (and then restoring) specific settings, I was hoping for >> settings to be set back just as they were before the test. > > Yah, but the good news is that the context manager/decorator hybrid > actually resets the settings completely (by temporarily wrapping it in a > UserSettingsHolder) and not only the overridden settings. That's because > the settings provided to the context manager/decorator is applied to the > wrapper not to the actual settings instance. > > In other words unless I misunderstand your use case it should just > revert to the setting instance that existed before, effectively reverting > your middleware's changes to the setting.
Ah, sorry, I didn't read the patch code closely enough. So yes, this addresses my need, and on second thought, I think the mutating middleware might do better to follow a similar pattern -- use UserSettingsHolder and swap the existing back in upon process_response or response_completed. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.