django.conf.settings.TEMPLATE_DEBUG

Here are the examples of the python api django.conf.settings.TEMPLATE_DEBUG taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: talk.org
Source File: loader_tags.py
View license
    def __init__(self, template_path):
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 2

Project: talk.org
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            t = get_template(template_name)
            return t.render(context)
        except TemplateSyntaxError, e:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''
        except:
            return '' # Fail silently for invalid included templates.

Example 3

Project: talk.org
Source File: __init__.py
View license
    def __init__(self, template_string, origin=None, name='<Unknown Template>'):
        try:
            template_string = smart_unicode(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 4

Project: talk.org
Source File: __init__.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 5

Project: GAE-Bulk-Mailer
Source File: base.py
View license
    def __init__(self, template_string, origin=None,
                 name='<Unknown Template>'):
        try:
            template_string = force_text(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed "
                                        "from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 6

Project: GAE-Bulk-Mailer
Source File: base.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from django.template.debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 7

Project: GAE-Bulk-Mailer
Source File: loader_tags.py
View license
    def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 8

Project: GAE-Bulk-Mailer
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 9

Project: PyClassLessons
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template = self.template.resolve(context)
            # Does this quack like a Template?
            if not callable(getattr(template, 'render', None)):
                # If not, we'll try get_template
                template = get_template(template)
            values = {
                name: var.resolve(context)
                for name, var in six.iteritems(self.extra_context)
            }
            if self.isolated_context:
                return template.render(context.new(values))
            with context.push(**values):
                return template.render(context)
        except Exception:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 10

Project: coursys
Source File: testcase.py
View license
    def _pre_setup(self):
        """Disable transaction methods, and clear some globals."""
        # Repeat stuff from TransactionTestCase, because I'm not calling its
        # _pre_setup, because that would load fixtures again.
        cache.cache.clear()
        settings.TEMPLATE_DEBUG = settings.DEBUG = False


        self.client = self.client_class()
        #self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

        # Clear site cache in case somebody's mutated Site objects and then
        # cached the mutated stuff:
        from django.contrib.sites.models import Site
        Site.objects.clear_cache()

Example 11

Project: splunk-webframework
Source File: base.py
View license
    def __init__(self, template_string, origin=None,
                 name='<Unknown Template>'):
        try:
            template_string = force_text(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed "
                                        "from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 12

Project: splunk-webframework
Source File: base.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from django.template.debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 13

Project: splunk-webframework
Source File: loader_tags.py
View license
    def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 14

Project: splunk-webframework
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 15

Project: Djinja
Source File: base.py
View license
    def render(self, context):
        context_dict = dict_from_context(context)
        if settings.TEMPLATE_DEBUG:
            from django.test import signals
            self.origin = Origin(self.filename)
            signals.template_rendered.send(sender=self, template=self, context=context)
    
        return super(Template, self).render(context_dict)

Example 16

Project: tendenci
Source File: theme_tags.py
View license
    def render(self, context):
        theme = context.get('THEME', get_setting('module', 'theme_editor', 'theme'))
        theme_template = get_theme_template(self.template_path, theme=theme)
        try:
            try:
                t = get_template(theme_template)
            except TemplateDoesNotExist:
                t = get_default_template(self.template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None
        if self.template:
            return self.template.render(context)
        else:
            return ''

Example 17

Project: tendenci
Source File: theme_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            theme = context.get('THEME', get_setting('module', 'theme_editor', 'theme'))
            theme_template = get_theme_template(template_name, theme=theme)
            try:
                t = get_template(theme_template)
            except TemplateDoesNotExist:
                t = get_default_template(template_name)
            return t.render(context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 18

Project: django-reversetag
Source File: reversetag.py
View license
    def __unicode__(self):
        # don't output partially reversed urls
        if settings.TEMPLATE_DEBUG:
            return u"[Cannot render: %r. You have to use it through " \
                   u"the 'reverse' tag.]" % self
        else:
            return u'' # fail silently

Example 19

Project: django-reversetag
Source File: reversetag.py
View license
    def __unicode__(self):
        # don't output partially reversed urls
        if settings.TEMPLATE_DEBUG:
            return "[Cannot render: %r. You have to use it through " \
                "the 'reverse' tag.]" % self
        else:
            return '' # fail silently

Example 20

Project: django-missing
Source File: context_tags.py
View license
    def render(self, context):
        try:
            context[self.variable] = self.nodelist.render(context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise

        return u''

Example 21

Project: django-missing
Source File: context_tags.py
View license
    def render(self, context):
        try:
            # We ignore the output
            self._render(context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
        return u''

Example 22

Project: django-missing
Source File: url_tags.py
View license
    def render(self, context):
        try:
            location = None
            if self.url:
                location = self.url.resolve(context)
            return context['request'].build_absolute_uri(location)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return u''

Example 23

Project: nodewatcher
Source File: menu_tags.py
View license
@register.assignment_tag(takes_context=True)
def get_menu(context, menu_name):
    try:
        menu = MenuEntries([entry.add_context(context) for entry in components.menus.get_menu(menu_name).entries if entry.is_visible(context['request'], context)])
        menu.name = menu_name
        return menu
    except:
        if settings.TEMPLATE_DEBUG:
            raise
        return []

Example 24

Project: nodewatcher
Source File: menu_tags.py
View license
@register.simple_tag(takes_context=True)
def render_menu_entry(context, menu_entry):
    try:
        # We could call menu_entry.add_context(context).render() as well,
        # but the following is performance-wise better
        return menu_entry.render(context)
    except:
        if settings.TEMPLATE_DEBUG:
            raise
        return u''

Example 25

Project: nodewatcher
Source File: partial_tags.py
View license
@register.assignment_tag(takes_context=True)
def get_partial(context, partial_name):
    try:
        partial = PartialEntries([entry.add_context(context) for entry in components.partials.get_partial(partial_name).entries if entry.is_visible(context['request'], context)])
        partial.name = partial_name
        return partial
    except:
        if settings.TEMPLATE_DEBUG:
            raise
        return []

Example 26

Project: nodewatcher
Source File: partial_tags.py
View license
@register.simple_tag(takes_context=True)
def render_partial_entry(context, partial_entry):
    try:
        # We could call partial_entry.add_context(context).render() as well,
        # but the following is performance-wise better
        return partial_entry.render(context)
    except:
        if settings.TEMPLATE_DEBUG:
            raise
        return u''

Example 27

Project: django-nonrel
Source File: base.py
View license
    def __init__(self, template_string, origin=None, name='<Unknown Template>'):
        try:
            template_string = smart_unicode(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 28

Project: django-nonrel
Source File: base.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 29

Project: django-nonrel
Source File: loader_tags.py
View license
    def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 30

Project: django-nonrel
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 31

Project: hue
Source File: loader_tags.py
View license
    def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 32

Project: hue
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 33

Project: decode-Django
Source File: base.py
View license
    def __init__(self, template_string, origin=None,
                 name='<Unknown Template>'):
        try:
            template_string = force_text(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed "
                                        "from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 34

Project: decode-Django
Source File: base.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from django.template.debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 35

Project: decode-Django
Source File: loader_tags.py
View license
    def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 36

Project: decode-Django
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 37

Project: django-compositepks
Source File: loader_tags.py
View license
    def __init__(self, template_path):
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 38

Project: django-compositepks
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            t = get_template(template_name)
            return t.render(context)
        except TemplateSyntaxError, e:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''
        except:
            return '' # Fail silently for invalid included templates.

Example 39

Project: django-compositepks
Source File: __init__.py
View license
    def __init__(self, template_string, origin=None, name='<Unknown Template>'):
        try:
            template_string = smart_unicode(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 40

Project: django-compositepks
Source File: __init__.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()

Example 41

Project: django-compositepks
Source File: tests.py
View license
    def setUp(self):
        # set TEMPLATE_DEBUG to True to ensure {% include %} will raise
        # exceptions since that is how inlines are rendered and #9498 will
        # bubble up if it is an issue.
        self.original_template_debug = settings.TEMPLATE_DEBUG
        settings.TEMPLATE_DEBUG = True
        self.client.login(username='super', password='secret')
        
        # Can't load content via a fixture (since the GenericForeignKey
        # relies on content type IDs, which will vary depending on what
        # other tests have been run), thus we do it here.
        e = Episode.objects.create(name='This Week in Django')
        m = Media(content_object=e, url='http://example.com/podcast.mp3')
        m.save()

Example 42

Project: django-lfs
Source File: sql.py
View license
    def render(self, context):
        if not settings.TEMPLATE_DEBUG:
            return ""
        secs = 0.0
        for s in db.connection.queries:
            secs += float(s['time'])
        return str("%d queries, %f seconds" % (len(db.connection.queries), secs)
)

Example 43

Project: django-lfs
Source File: sql.py
View license
    def render(self, context):
        if not settings.TEMPLATE_DEBUG:
            return ""
        s = ""
        for q in db.connection.queries:
            s += "<li>" + escape(q["sql"]) + "</li>\n"
        return s

Example 44

Project: django-bmf
Source File: djangobmf_forms.py
View license
    def render(self, context):
        try:
            t = get_template(self.template_path)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''
        return t.render(context)

Example 45

Project: django-cache-machine
Source File: ext.py
View license
    def _cache_support(self, name, obj, timeout, extra, caller):
        """Cache helper callback."""
        if settings.TEMPLATE_DEBUG:
            return caller()
        extra = ':'.join(map(encoding.smart_str, extra))
        key = 'fragment:%s:%s' % (name, extra)
        return caching.base.cached_with(obj, caller, key, timeout)

Example 46

Project: django-nose
Source File: testcases.py
View license
    def _pre_setup(self):
        """Disable transaction methods, and clear some globals."""
        # Repeat stuff from TransactionTestCase, because I'm not calling its
        # _pre_setup, because that would load fixtures again.
        cache.cache.clear()
        settings.TEMPLATE_DEBUG = settings.DEBUG = False

        test.testcases.disable_transaction_methods()

        self.client = self.client_class()
        # self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

        # Clear site cache in case somebody's mutated Site objects and then
        # cached the mutated stuff:
        from django.contrib.sites.models import Site
        Site.objects.clear_cache()

Example 47

Project: lettuce
Source File: loader_tags.py
View license
    def __init__(self, template_path):
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None

Example 48

Project: lettuce
Source File: loader_tags.py
View license
    def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            t = get_template(template_name)
            return t.render(context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return ''

Example 49

Project: lettuce
Source File: __init__.py
View license
    def __init__(self, template_string, origin=None, name='<Unknown Template>'):
        try:
            template_string = smart_unicode(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name

Example 50

Project: lettuce
Source File: __init__.py
View license
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse()