mozilla / django-browserid

Django application for adding BrowserID support.
Mozilla Public License 2.0
180 stars 80 forks source link

Add support for lazily-evaluated BROWSERID_REQUEST_ARGS. #154

Closed Osmose closed 11 years ago

Osmose commented 11 years ago

Updates our use of BROWSERID_REQUEST_ARGS to support Django Promises. This is primarily useful for translating strings in the request args using lazy translation, as well as reversing URLs using reverse_lazy.

peterbe commented 11 years ago

Excellent! Can't find anything wrong. r+

I guess I don't really understand it actually. When you do request_args = dict(getattr(settings, ... what type does request_args become at that point? A <type dict> or some sort of lazy object?

Osmose commented 11 years ago

It becomes a dict. Calling dict on it forces evaluation of the lazy value at that moment. Same with the LazyEncoder: it uses unicode to force evaluation only when we finally need the value. And since that happens during a request, the localization and reversing work as expected.

peterbe commented 11 years ago

It looks good to me. I don't really get it about the unicode promises and how that relates to l10n but I feel you're a couple of steps ahead on that one.

Want me to merge it?