Loading django/shortcuts.py +5 −7 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ from django.http import ( ) from django.template import RequestContext, loader from django.template.engine import ( _context_instance_undefined, _dictionary_undefined, _dirs_undefined, _context_instance_undefined, _dictionary_undefined ) from django.utils import six from django.utils.encoding import force_text Loading @@ -21,14 +21,13 @@ from django.utils.functional import Promise def render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, content_type=None, status=None, dictionary=_dictionary_undefined, using=None): """ Returns a HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path content = loader.render_to_string(template_name, context, using=using) Loading @@ -36,7 +35,7 @@ def render_to_response(template_name, context=None, else: # Some deprecated arguments were passed - use the legacy code path content = loader.render_to_string( template_name, context, context_instance, dirs, dictionary, template_name, context, context_instance, dictionary, using=using) return HttpResponse(content, content_type, status) Loading @@ -45,7 +44,7 @@ def render_to_response(template_name, context=None, def render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, dictionary=_dictionary_undefined, dictionary=_dictionary_undefined, using=None): """ Returns a HttpResponse whose content is filled with the result of calling Loading @@ -53,7 +52,6 @@ def render(request, template_name, context=None, Uses a RequestContext by default. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path # In Django 1.10, request should become a positional argument. Loading @@ -66,7 +64,7 @@ def render(request, template_name, context=None, else: context_instance = RequestContext(request) content = loader.render_to_string( template_name, context, context_instance, dirs, dictionary, template_name, context, context_instance, dictionary, using=using) return HttpResponse(content, content_type, status) Loading django/template/backends/django.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ from django.apps import apps from django.conf import settings from django.template import TemplateDoesNotExist from django.template.context import Context, RequestContext, make_context from django.template.engine import Engine, _dirs_undefined from django.template.engine import Engine from django.template.library import InvalidTemplateLibrary from django.utils import six from django.utils.deprecation import RemovedInDjango110Warning Loading @@ -35,9 +35,9 @@ class DjangoTemplates(BaseEngine): def from_string(self, template_code): return Template(self.engine.from_string(template_code), self) def get_template(self, template_name, dirs=_dirs_undefined): def get_template(self, template_name): try: return Template(self.engine.get_template(template_name, dirs), self) return Template(self.engine.get_template(template_name), self) except TemplateDoesNotExist as exc: reraise(exc, self) Loading django/template/engine.py +6 −32 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ from .library import import_library _context_instance_undefined = object() _dictionary_undefined = object() _dirs_undefined = object() class Engine(object): Loading Loading @@ -167,19 +166,12 @@ class Engine(object): """ return Template(template_code, engine=self) def get_template(self, template_name, dirs=_dirs_undefined): def get_template(self, template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ if dirs is _dirs_undefined: dirs = None else: warnings.warn( "The dirs argument of get_template is deprecated.", RemovedInDjango110Warning, stacklevel=2) template, origin = self.find_template(template_name, dirs) template, origin = self.find_template(template_name) if not hasattr(template, 'render'): # template needs to be compiled template = Template(template, origin, template_name, engine=self) Loading @@ -193,7 +185,6 @@ class Engine(object): def render_to_string(self, template_name, context=None, context_instance=_context_instance_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined): if context_instance is _context_instance_undefined: context_instance = None Loading @@ -201,14 +192,6 @@ class Engine(object): warnings.warn( "The context_instance argument of render_to_string is " "deprecated.", RemovedInDjango110Warning, stacklevel=2) if dirs is _dirs_undefined: # Do not set dirs to None here to avoid triggering the deprecation # warning in select_template or get_template. pass else: warnings.warn( "The dirs argument of render_to_string is deprecated.", RemovedInDjango110Warning, stacklevel=2) if dictionary is _dictionary_undefined: dictionary = None else: Loading @@ -218,9 +201,9 @@ class Engine(object): context = dictionary if isinstance(template_name, (list, tuple)): t = self.select_template(template_name, dirs) t = self.select_template(template_name) else: t = self.get_template(template_name, dirs) t = self.get_template(template_name) if not context_instance: # Django < 1.8 accepted a Context in `context` even though that's # unintended. Preserve this ability but don't rewrap `context`. Loading @@ -235,25 +218,16 @@ class Engine(object): with context_instance.push(context): return t.render(context_instance) def select_template(self, template_name_list, dirs=_dirs_undefined): def select_template(self, template_name_list): """ Given a list of template names, returns the first that can be loaded. """ if dirs is _dirs_undefined: # Do not set dirs to None here to avoid triggering the deprecation # warning in get_template. pass else: warnings.warn( "The dirs argument of select_template is deprecated.", RemovedInDjango110Warning, stacklevel=2) if not template_name_list: raise TemplateDoesNotExist("No template names provided") not_found = [] for template_name in template_name_list: try: return self.get_template(template_name, dirs) return self.get_template(template_name) except TemplateDoesNotExist as exc: if exc.args[0] not in not_found: not_found.append(exc.args[0]) Loading django/template/loader.py +6 −35 Original line number Diff line number Diff line Loading @@ -4,14 +4,12 @@ from django.utils.deprecation import RemovedInDjango110Warning from . import engines from .backends.django import DjangoTemplates from .engine import ( _context_instance_undefined, _dictionary_undefined, _dirs_undefined, ) from .engine import _context_instance_undefined, _dictionary_undefined from .exceptions import TemplateDoesNotExist from .loaders import base def get_template(template_name, dirs=_dirs_undefined, using=None): def get_template(template_name, using=None): """ Loads and returns a template for the given name. Loading @@ -21,16 +19,6 @@ def get_template(template_name, dirs=_dirs_undefined, using=None): engines = _engine_list(using) for engine in engines: try: # This is required for deprecating the dirs argument. Simply # return engine.get_template(template_name) in Django 1.10. if isinstance(engine, DjangoTemplates): return engine.get_template(template_name, dirs) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its get_template " "method doesn't support the dirs argument." % engine.name, stacklevel=2) else: return engine.get_template(template_name) except TemplateDoesNotExist as e: chain.append(e) Loading @@ -38,7 +26,7 @@ def get_template(template_name, dirs=_dirs_undefined, using=None): raise TemplateDoesNotExist(template_name, chain=chain) def select_template(template_name_list, dirs=_dirs_undefined, using=None): def select_template(template_name_list, using=None): """ Loads and returns a template for one of the given names. Loading @@ -51,16 +39,6 @@ def select_template(template_name_list, dirs=_dirs_undefined, using=None): for template_name in template_name_list: for engine in engines: try: # This is required for deprecating the dirs argument. Simply # use engine.get_template(template_name) in Django 1.10. if isinstance(engine, DjangoTemplates): return engine.get_template(template_name, dirs) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its get_template " "method doesn't support the dirs argument." % engine.name, stacklevel=2) else: return engine.get_template(template_name) except TemplateDoesNotExist as e: chain.append(e) Loading @@ -73,7 +51,6 @@ def select_template(template_name_list, dirs=_dirs_undefined, using=None): def render_to_string(template_name, context=None, context_instance=_context_instance_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined, request=None, using=None): """ Loading @@ -82,7 +59,6 @@ def render_to_string(template_name, context=None, template_name may be a string or a list of strings. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path if isinstance(template_name, (list, tuple)): Loading @@ -106,17 +82,12 @@ def render_to_string(template_name, context=None, "when some deprecated arguments are passed.") # Hack -- use the internal Engine instance of DjangoTemplates. return engine.engine.render_to_string( template_name, context, context_instance, dirs, dictionary) template_name, context, context_instance, dictionary) elif context_instance is not _context_instance_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " "method doesn't support the context_instance argument." % engine.name, stacklevel=2) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " "method doesn't support the dirs argument." % engine.name, stacklevel=2) elif dictionary is not _dictionary_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " Loading docs/topics/http/shortcuts.txt +2 −10 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ introduce controlled coupling for convenience's sake. ``render`` ========== .. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None) .. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None) Combines a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. Loading Loading @@ -75,10 +75,6 @@ Optional arguments The ``using`` parameter was added. .. deprecated:: 1.8 The ``dirs`` parameter was deprecated. Example ------- Loading Loading @@ -107,7 +103,7 @@ This example is equivalent to:: ``render_to_response`` ====================== .. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None) .. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None) Renders a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. Loading Loading @@ -165,10 +161,6 @@ Optional arguments The ``status`` and ``using`` parameters were added. .. deprecated:: 1.8 The ``dirs`` parameter was deprecated. Example ------- Loading Loading
django/shortcuts.py +5 −7 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ from django.http import ( ) from django.template import RequestContext, loader from django.template.engine import ( _context_instance_undefined, _dictionary_undefined, _dirs_undefined, _context_instance_undefined, _dictionary_undefined ) from django.utils import six from django.utils.encoding import force_text Loading @@ -21,14 +21,13 @@ from django.utils.functional import Promise def render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, content_type=None, status=None, dictionary=_dictionary_undefined, using=None): """ Returns a HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path content = loader.render_to_string(template_name, context, using=using) Loading @@ -36,7 +35,7 @@ def render_to_response(template_name, context=None, else: # Some deprecated arguments were passed - use the legacy code path content = loader.render_to_string( template_name, context, context_instance, dirs, dictionary, template_name, context, context_instance, dictionary, using=using) return HttpResponse(content, content_type, status) Loading @@ -45,7 +44,7 @@ def render_to_response(template_name, context=None, def render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, dictionary=_dictionary_undefined, dictionary=_dictionary_undefined, using=None): """ Returns a HttpResponse whose content is filled with the result of calling Loading @@ -53,7 +52,6 @@ def render(request, template_name, context=None, Uses a RequestContext by default. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path # In Django 1.10, request should become a positional argument. Loading @@ -66,7 +64,7 @@ def render(request, template_name, context=None, else: context_instance = RequestContext(request) content = loader.render_to_string( template_name, context, context_instance, dirs, dictionary, template_name, context, context_instance, dictionary, using=using) return HttpResponse(content, content_type, status) Loading
django/template/backends/django.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ from django.apps import apps from django.conf import settings from django.template import TemplateDoesNotExist from django.template.context import Context, RequestContext, make_context from django.template.engine import Engine, _dirs_undefined from django.template.engine import Engine from django.template.library import InvalidTemplateLibrary from django.utils import six from django.utils.deprecation import RemovedInDjango110Warning Loading @@ -35,9 +35,9 @@ class DjangoTemplates(BaseEngine): def from_string(self, template_code): return Template(self.engine.from_string(template_code), self) def get_template(self, template_name, dirs=_dirs_undefined): def get_template(self, template_name): try: return Template(self.engine.get_template(template_name, dirs), self) return Template(self.engine.get_template(template_name), self) except TemplateDoesNotExist as exc: reraise(exc, self) Loading
django/template/engine.py +6 −32 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ from .library import import_library _context_instance_undefined = object() _dictionary_undefined = object() _dirs_undefined = object() class Engine(object): Loading Loading @@ -167,19 +166,12 @@ class Engine(object): """ return Template(template_code, engine=self) def get_template(self, template_name, dirs=_dirs_undefined): def get_template(self, template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ if dirs is _dirs_undefined: dirs = None else: warnings.warn( "The dirs argument of get_template is deprecated.", RemovedInDjango110Warning, stacklevel=2) template, origin = self.find_template(template_name, dirs) template, origin = self.find_template(template_name) if not hasattr(template, 'render'): # template needs to be compiled template = Template(template, origin, template_name, engine=self) Loading @@ -193,7 +185,6 @@ class Engine(object): def render_to_string(self, template_name, context=None, context_instance=_context_instance_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined): if context_instance is _context_instance_undefined: context_instance = None Loading @@ -201,14 +192,6 @@ class Engine(object): warnings.warn( "The context_instance argument of render_to_string is " "deprecated.", RemovedInDjango110Warning, stacklevel=2) if dirs is _dirs_undefined: # Do not set dirs to None here to avoid triggering the deprecation # warning in select_template or get_template. pass else: warnings.warn( "The dirs argument of render_to_string is deprecated.", RemovedInDjango110Warning, stacklevel=2) if dictionary is _dictionary_undefined: dictionary = None else: Loading @@ -218,9 +201,9 @@ class Engine(object): context = dictionary if isinstance(template_name, (list, tuple)): t = self.select_template(template_name, dirs) t = self.select_template(template_name) else: t = self.get_template(template_name, dirs) t = self.get_template(template_name) if not context_instance: # Django < 1.8 accepted a Context in `context` even though that's # unintended. Preserve this ability but don't rewrap `context`. Loading @@ -235,25 +218,16 @@ class Engine(object): with context_instance.push(context): return t.render(context_instance) def select_template(self, template_name_list, dirs=_dirs_undefined): def select_template(self, template_name_list): """ Given a list of template names, returns the first that can be loaded. """ if dirs is _dirs_undefined: # Do not set dirs to None here to avoid triggering the deprecation # warning in get_template. pass else: warnings.warn( "The dirs argument of select_template is deprecated.", RemovedInDjango110Warning, stacklevel=2) if not template_name_list: raise TemplateDoesNotExist("No template names provided") not_found = [] for template_name in template_name_list: try: return self.get_template(template_name, dirs) return self.get_template(template_name) except TemplateDoesNotExist as exc: if exc.args[0] not in not_found: not_found.append(exc.args[0]) Loading
django/template/loader.py +6 −35 Original line number Diff line number Diff line Loading @@ -4,14 +4,12 @@ from django.utils.deprecation import RemovedInDjango110Warning from . import engines from .backends.django import DjangoTemplates from .engine import ( _context_instance_undefined, _dictionary_undefined, _dirs_undefined, ) from .engine import _context_instance_undefined, _dictionary_undefined from .exceptions import TemplateDoesNotExist from .loaders import base def get_template(template_name, dirs=_dirs_undefined, using=None): def get_template(template_name, using=None): """ Loads and returns a template for the given name. Loading @@ -21,16 +19,6 @@ def get_template(template_name, dirs=_dirs_undefined, using=None): engines = _engine_list(using) for engine in engines: try: # This is required for deprecating the dirs argument. Simply # return engine.get_template(template_name) in Django 1.10. if isinstance(engine, DjangoTemplates): return engine.get_template(template_name, dirs) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its get_template " "method doesn't support the dirs argument." % engine.name, stacklevel=2) else: return engine.get_template(template_name) except TemplateDoesNotExist as e: chain.append(e) Loading @@ -38,7 +26,7 @@ def get_template(template_name, dirs=_dirs_undefined, using=None): raise TemplateDoesNotExist(template_name, chain=chain) def select_template(template_name_list, dirs=_dirs_undefined, using=None): def select_template(template_name_list, using=None): """ Loads and returns a template for one of the given names. Loading @@ -51,16 +39,6 @@ def select_template(template_name_list, dirs=_dirs_undefined, using=None): for template_name in template_name_list: for engine in engines: try: # This is required for deprecating the dirs argument. Simply # use engine.get_template(template_name) in Django 1.10. if isinstance(engine, DjangoTemplates): return engine.get_template(template_name, dirs) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its get_template " "method doesn't support the dirs argument." % engine.name, stacklevel=2) else: return engine.get_template(template_name) except TemplateDoesNotExist as e: chain.append(e) Loading @@ -73,7 +51,6 @@ def select_template(template_name_list, dirs=_dirs_undefined, using=None): def render_to_string(template_name, context=None, context_instance=_context_instance_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined, request=None, using=None): """ Loading @@ -82,7 +59,6 @@ def render_to_string(template_name, context=None, template_name may be a string or a list of strings. """ if (context_instance is _context_instance_undefined and dirs is _dirs_undefined and dictionary is _dictionary_undefined): # No deprecated arguments were passed - use the new code path if isinstance(template_name, (list, tuple)): Loading @@ -106,17 +82,12 @@ def render_to_string(template_name, context=None, "when some deprecated arguments are passed.") # Hack -- use the internal Engine instance of DjangoTemplates. return engine.engine.render_to_string( template_name, context, context_instance, dirs, dictionary) template_name, context, context_instance, dictionary) elif context_instance is not _context_instance_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " "method doesn't support the context_instance argument." % engine.name, stacklevel=2) elif dirs is not _dirs_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " "method doesn't support the dirs argument." % engine.name, stacklevel=2) elif dictionary is not _dictionary_undefined: warnings.warn( "Skipping template backend %s because its render_to_string " Loading
docs/topics/http/shortcuts.txt +2 −10 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ introduce controlled coupling for convenience's sake. ``render`` ========== .. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None) .. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None) Combines a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. Loading Loading @@ -75,10 +75,6 @@ Optional arguments The ``using`` parameter was added. .. deprecated:: 1.8 The ``dirs`` parameter was deprecated. Example ------- Loading Loading @@ -107,7 +103,7 @@ This example is equivalent to:: ``render_to_response`` ====================== .. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None) .. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, using=None) Renders a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. Loading Loading @@ -165,10 +161,6 @@ Optional arguments The ``status`` and ``using`` parameters were added. .. deprecated:: 1.8 The ``dirs`` parameter was deprecated. Example ------- Loading