On 12/01/2010 05:05 PM, Łukasz Rekucki wrote:
from django.conf import settingsdef without_localization(view): @wraps(view): def decorated(*args, **kwargs): # NOTE: I'm assuming this will actually have any effect - settings caching is a different issue old_value, settings.USE_L10N = settings.USE_L10N, False try: # If view uses HttpResponse, the template will be rendered with USE_L10N = False # If it uses TemplateResponse, nothing will be rendered (yet!) return view(*args, **kwargs) finally: # USE_L10N will be back to it's original value # and that value will be used at the time of baking settings.USE_L10N = old_value return decorated
Ugh :-(. Thanks, I'll keep it in my notebook of examples where imperative style sucks…
But I see your point now. Indeed there are cases where TemplateResponse is not a transparent replacement for HttpResponse. I'll crawl back to my cave now and cry a little.
-- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
