mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.9.x] Fixed #25466 -- Added backwards compatibility aliases for LoaderOrigin and StringOrigin.
Thanks Simon Charette for the DeprecationInstanceCheck class.
Backport of 8d1a001ef6 from master
This commit is contained in:
@@ -58,7 +58,8 @@ from .exceptions import TemplateDoesNotExist, TemplateSyntaxError # NOQA i
|
||||
|
||||
# Template parts
|
||||
from .base import ( # NOQA isort:skip
|
||||
Context, Node, NodeList, Origin, RequestContext, Template, Variable,
|
||||
Context, Node, NodeList, Origin, RequestContext, StringOrigin, Template,
|
||||
Variable,
|
||||
)
|
||||
|
||||
# Deprecated in Django 1.8, will be removed in Django 1.10.
|
||||
|
||||
@@ -60,7 +60,10 @@ from django.template.context import ( # NOQA: imported for backwards compatibil
|
||||
BaseContext, Context, ContextPopException, RequestContext,
|
||||
)
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.deprecation import (
|
||||
DeprecationInstanceCheck, RemovedInDjango20Warning,
|
||||
RemovedInDjango110Warning,
|
||||
)
|
||||
from django.utils.encoding import (
|
||||
force_str, force_text, python_2_unicode_compatible,
|
||||
)
|
||||
@@ -158,6 +161,11 @@ class Origin(object):
|
||||
)
|
||||
|
||||
|
||||
class StringOrigin(six.with_metaclass(DeprecationInstanceCheck, Origin)):
|
||||
alternative = 'django.template.Origin'
|
||||
deprecation_warning = RemovedInDjango20Warning
|
||||
|
||||
|
||||
class Template(object):
|
||||
def __init__(self, template_string, origin=None, name=None, engine=None):
|
||||
try:
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import warnings
|
||||
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import (
|
||||
DeprecationInstanceCheck, RemovedInDjango20Warning,
|
||||
RemovedInDjango110Warning,
|
||||
)
|
||||
|
||||
from . import engines
|
||||
from .backends.django import DjangoTemplates
|
||||
from .base import Origin
|
||||
from .engine import (
|
||||
_context_instance_undefined, _dictionary_undefined, _dirs_undefined,
|
||||
)
|
||||
@@ -147,3 +152,8 @@ class BaseLoader(base.Loader):
|
||||
"django.template.loaders.base.Loader.",
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
super(BaseLoader, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class LoaderOrigin(six.with_metaclass(DeprecationInstanceCheck, Origin)):
|
||||
alternative = 'django.template.Origin'
|
||||
deprecation_warning = RemovedInDjango20Warning
|
||||
|
||||
Reference in New Issue
Block a user