﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33525	decorator @html_safe removes completely old class.__str__ method.	Maxim Danilov	nobody	"I can not to get normal __str__ method from safe_string.

Fro example:


{{{
@html_safe
class TranslatableText(str):
    """"""Class like a string but returns values depends on get_language.""""""
}}}

After that str(TranslatableText) is always SafeString. If i want call old __str__ method it is not possible: html_safe destroy it in django\utils\html.py, rows 376-378
{{{
    klass_str = klass.__str__
    klass.__str__ = lambda self: mark_safe(klass_str(self))
    klass.__html__ = lambda self: str(self)
    return klass
}}}
But it is easy to repair:
{{{
    klass._old_str_method = klass.__str__
    klass.__str__ = lambda self: mark_safe(klass._old_str_method(self))
    klass.__html__ = lambda self: str(self)
    return klass
}}}
After that, not only can i get SafeString object, it is also possible to call klass._old_str_method and get BaseString object"	Cleanup/optimization	closed	Utilities	4.0	Normal	wontfix	html_string, SafeString		Unreviewed	1	0	0	0	1	0
