def fallback(request, url): if url.find('..') > -1: raise Http404('Page not found.') if not re_staticfilenames.match(url): raise Http404('Page not found.') if len(url) > 250: # Maximum length is really per-directory, but we shouldn't have any pages/fallback # urls with anywhere *near* that, so let's just limit it on the whole raise Http404('Page not found.') try: t = loader.get_template('pages/%s.html' % url) except TemplateDoesNotExist: try: t = loader.get_template('pages/%s/en.html' % url) except TemplateDoesNotExist: raise Http404('Page not found.') # Guestimate the nav section by looking at the URL and taking the first # piece of it. try: navsect = url.split('/', 2)[0] except Exception as e: navsect = '' c = PGWebContextProcessor(request) c.update({'navmenu': get_nav_menu(navsect)}) return HttpResponse(t.render(c))
def fallback(request, url): if url.find('..') > -1: raise Http404('Page not found.') if not re_staticfilenames.match(url): raise Http404('Page not found.') try: t = loader.get_template('pages/%s.html' % url) except TemplateDoesNotExist: try: t = loader.get_template('pages/%s/en.html' % url) except TemplateDoesNotExist: raise Http404('Page not found.') # Guestimate the nav section by looking at the URL and taking the first # piece of it. try: navsect = url.split('/', 2)[0] except: navsect = '' return HttpResponse(t.render({'navmenu': get_nav_menu(navsect)}))
def fallback(request, url): if url.find('..') > -1: raise Http404('Page not found.') if not re_staticfilenames.match(url): raise Http404('Page not found.') try: t = loader.get_template('pages/%s.html' % url) except TemplateDoesNotExist: try: t = loader.get_template('pages/%s/en.html' % url) except TemplateDoesNotExist: raise Http404('Page not found.') # Guestimate the nav section by looking at the URL and taking the first # piece of it. try: navsect = url.split('/', 2)[0] except: navsect = '' c = PGWebContextProcessor(request) c.update({'navmenu': get_nav_menu(navsect)}) return HttpResponse(t.render(c))