from utils import Node

def page_display(ctx):
    ctx.run_template('tree.html')


def page_process(ctx):
    if ctx.req_equals('paginate'):
        ctx.redirect('paginate')
    if not hasattr(ctx.locals, 'tree'):
        ctx.locals.tree \
            = Node('a', [Node('a', [Node('a'),
                                    Node('b')]),
                         Node('b', [Node('a', [Node('a', [Node('a'),
                                                          Node('b')])]),
                                    Node('b'),
                                    Node('c', [Node('a'),
                                               Node('b')])])])
        ctx.add_session_vars('tree')
