def make_view(response): def view(request): return HttpResponse(response) return view ######################## ### URLS FOR TESTING ######################## ######################## ### Normal section section = Section('base') # Add with no children add0 = section.add('add0').configure(target=make_view('/add0/')) # Add with children, no first add1 = section.add('add1').configure(target=make_view('/add1/')) add12 = add1.add('add12').configure(target=make_view('/add1/add12/')) add123 = add12.add('add123').configure(target=make_view('/add1/add12/add123/')) # Add with no target and no children add_nt0 = section.add('add_nt0') # Add with no target and children add_nt1 = section.add('add_nt1') add_nt12 = add_nt1.add('add_nt12').configure(target=make_view('/add_nt1/add_nt12/')) # Add with no target and no children but a first add_ntf0 = section.add('add_ntf0')
def view(request, *args, **kwargs): res = HttpResponse(response) res.section = request.section return res return view ######################## ### URLS FOR TESTING ######################## ######################## ### Normal section root = Section('').configure(promote_children=True, namespace='root') root.add("one").configure(target=make_view("one")) root.add("two").configure(target=make_view("two")) three = root.add("three").configure(target=make_view("three")) three.add("other").configure(target=make_view("three/other")) three.add("three_child2").configure(target=make_view("three/three_child2")) four = root.add("four").configure(target=make_view("four")) four.add("jother").configure(target=make_view("four/other")) five = root.add("five").configure(target=make_view("five"), promote_children=True) six = five.add("six").configure(target=make_view("five/six")) seven = five.add("seven").configure(target=make_view("five/seven")) seven_v1 = seven.add('\d{4}').configure(''
res = HttpResponse(response) res.section = request.section return res return view ######################## ### URLS FOR TESTING ######################## section = Section('', name="templatetest") section.first().configure(alias="Home") ######################## ### SECTION1 sect1 = section.add('one').configure(target=make_view("/one/")) sect1_some = sect1.add('some').configure(alias='blah', target=make_view("/one/some/")) sect1_blah = sect1.add('\w+').configure( match = 'blah' , target=make_view("/one/<blah>/") , values = Values( lambda info : ['2', '1', '3'] , lambda info, value : ('%s_url' % value, 'alias_%s' % value) , sorter = True ) ) ######################## ### SECTION2 sect2 = section.add('2').configure(alias='two')