1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Description: Defines our own StrAndUnicode class
The StrAndUnicode class has been removed from Django 1.7, so we remove the
use of the Django one and replace it by a copy/past in the upstream code.
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/765160
Forwarded: no
Last-Update: 2014-10-17
--- python-jingo-0.7.orig/jingo/monkey.py
+++ python-jingo-0.7/jingo/monkey.py
@@ -54,10 +54,19 @@ def __html__(self):
return six.text_type(self)
+class StrAndUnicode(object):
+ """
+ A class whose __str__ returns its __unicode__ as a UTF-8 bytestring.
+
+ Useful as a mix-in.
+ """
+ def __str__(self):
+ return self.__unicode__().encode('utf-8')
+
# Django uses StrAndUnicode for classes like Form, BoundField, Widget which
# have a __unicode__ method which returns escaped html. We replace
# StrAndUnicode with SafeStrAndUnicode to get the __html__ method.
-class SafeStrAndUnicode(django.utils.encoding.StrAndUnicode):
+class SafeStrAndUnicode(StrAndUnicode):
"""A class whose __str__ and __html__ returns __unicode__."""
def __html__(self):
@@ -86,8 +95,8 @@ def patch():
for cls in classes:
bases = list(cls.__bases__)
- if django.utils.encoding.StrAndUnicode in bases:
- idx = bases.index(django.utils.encoding.StrAndUnicode)
+ if StrAndUnicode in bases:
+ idx = bases.index(StrAndUnicode)
bases[idx] = SafeStrAndUnicode
cls.__bases__ = tuple(bases)
for cls in classes:
|