Commit d17a0351 authored by Preston Timmons's avatar Preston Timmons
Browse files

Moved engine-related exceptions to django.template.exceptions.

With the introduction of multiple template engines these exceptions are no
longer DTL-specific. It makes more sense for them to be moved out of
DTL-related modules.
parent adff499e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -54,9 +54,9 @@ __all__ = ('Engine', 'engines')
# Django Template Language

# Public exceptions
from .base import (TemplateDoesNotExist, TemplateSyntaxError,           # NOQA
                   VariableDoesNotExist)
from .base import VariableDoesNotExist                                  # NOQA
from .context import ContextPopException                                # NOQA
from .exceptions import TemplateDoesNotExist, TemplateSyntaxError       # NOQA

# Template parts
from .base import (Context, Node, NodeList, Origin, RequestContext,     # NOQA
+2 −30
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ from django.utils.text import (
from django.utils.timezone import template_localtime
from django.utils.translation import pgettext_lazy, ugettext_lazy

from .exceptions import TemplateSyntaxError

TOKEN_TEXT = 0
TOKEN_VAR = 1
TOKEN_BLOCK = 2
@@ -129,36 +131,6 @@ builtins = []
logger = logging.getLogger('django.template')


class TemplateSyntaxError(Exception):
    pass


class TemplateDoesNotExist(Exception):
    """
    The exception used by backends when a template does not exist. Accepts the
    following optional arguments:

    backend
        The template backend class used when raising this exception.

    tried
        A list of sources that were tried when finding the template. This
        is formatted as a list of tuples containing (origin, status), where
        origin is an Origin object and status is a string with the reason the
        template wasn't found.

    chain
        A list of intermediate TemplateDoesNotExist exceptions. This is used to
        encapsulate multiple exceptions when loading templates from multiple
        engines.
    """
    def __init__(self, msg, tried=None, backend=None, chain=None):
        self.backend = backend
        self.tried = tried or []
        self.chain = chain or []
        super(TemplateDoesNotExist, self).__init__(msg)


class TemplateEncodingError(Exception):
    pass

+2 −1
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ from functools import wraps
from pprint import pformat

from django.conf import settings
from django.template.base import Library, Variable, VariableDoesNotExist
from django.utils import formats, six
from django.utils.dateformat import format, time_format
from django.utils.deprecation import RemovedInDjango20Warning
@@ -26,6 +25,8 @@ from django.utils.text import (
from django.utils.timesince import timesince, timeuntil
from django.utils.translation import ugettext, ungettext

from .base import Library, Variable, VariableDoesNotExist

register = Library()


+10 −9
Original line number Diff line number Diff line
@@ -9,7 +9,14 @@ from datetime import datetime
from itertools import cycle as itertools_cycle, groupby

from django.conf import settings
from django.template.base import (
from django.utils import six, timezone
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, smart_text
from django.utils.html import format_html
from django.utils.lorem_ipsum import paragraphs, words
from django.utils.safestring import mark_safe

from .base import (
    BLOCK_TAG_END, BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START,
    SINGLE_BRACE_END, SINGLE_BRACE_START, VARIABLE_ATTRIBUTE_SEPARATOR,
    VARIABLE_TAG_END, VARIABLE_TAG_START, Context, InvalidTemplateLibrary,
@@ -17,14 +24,8 @@ from django.template.base import (
    VariableDoesNotExist, get_library, kwarg_re, render_value_in_context,
    token_kwargs,
)
from django.template.defaultfilters import date
from django.template.smartif import IfParser, Literal
from django.utils import six, timezone
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, smart_text
from django.utils.html import format_html
from django.utils.lorem_ipsum import paragraphs, words
from django.utils.safestring import mark_safe
from .defaultfilters import date
from .smartif import IfParser, Literal

register = Library()

+2 −1
Original line number Diff line number Diff line
@@ -6,8 +6,9 @@ from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string

from .base import Context, Template, TemplateDoesNotExist
from .base import Context, Template
from .context import _builtin_context_processors
from .exceptions import TemplateDoesNotExist

_context_instance_undefined = object()
_dictionary_undefined = object()
Loading