PageRenderTime 38ms CodeModel.GetById 27ms app.highlight 3ms RepoModel.GetById 7ms app.codeStats 0ms

/gdt_breadcrumbs/templatetags/breadcrumbs.py

http://greatlemers-django-tools.googlecode.com/
Python | 17 lines | 15 code | 2 blank | 0 comment | 6 complexity | 6f82e1cbdb55240e7aa37ef5085f91f3 MD5 | raw file
 1from django import template
 2
 3register = template.Library()
 4
 5@register.inclusion_tag('breadcrumb_tag.djt', takes_context=True)
 6def breadcrumb_trail(context):
 7  from gdt_breadcrumbs import BREADCRUMB_URL, BREADCRUMB_TRAIL
 8  from django.conf import settings
 9  trail = []
10  if 'request' in context:
11    urls = context['request'].session.get(BREADCRUMB_URL, [])
12    crumbs = context['request'].session.get(BREADCRUMB_TRAIL, {})
13    for url in urls:
14      trail.append((url, crumbs.get(url, url)))
15  if not trail:
16    trail = ((settings.GDT_BREADCRUMB_ROOT_URL, settings.GDT_BREADCRUMB_ROOT_TITLE),)
17  return { 'breadcrumbs' : trail }