#21882: Early modification bug in Django 1.6. with mark_safe + ugettext_lazy
-------------------------------------+-------------------------------------
     Reporter:  nealtodd             |                    Owner:  bmispelon
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  1.6
  Internationalization               |               Resolution:
     Severity:  Release blocker      |             Triage Stage:  Accepted
     Keywords:  mark_safe            |      Needs documentation:  0
  ugettext_lazy                      |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by bmispelon):

 * has_patch:  0 => 1


Comment:

 Well, this turned out to be more complicated than what I originally
 thought.

 Calling `force_text` inside the function works but only because it removes
 the lazy property of the string which is not really what you want.

 What's needed instead is a way to mark `Promise` objects as safe but while
 still delaying their evaluation.
 I achieved this by creating subclasses of both `Promise` and `SafeData`
 and the result seems to be working (all the test pass and the regression
 test I added is fixed).

 Here's the pull request: https://github.com/django/django/pull/2234/files
 Reviews welcome.

 Hopefully this should make it into the upcoming 1.6.2 release, provided I
 can get another set of eyes on the patch to make sure it's not doing
 anything too crazy.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21882#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.d5d22d0817a1553f036d9bb9bef74991%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to