pvl/verkko/urls.py
author Tero Marttila <terom@paivola.fi>
Wed, 24 Oct 2012 16:04:41 +0300
changeset 19 4e2e26f4d058
parent 13 a2f245750700
child 25 47faf2ac32d0
permissions -rw-r--r--
pvl.verkko.hosts: multi-value filters
from werkzeug.routing import Map, Rule

def rule (string, endpoint, **opts) :
    return Rule(string, endpoint=endpoint, **opts)

# URL -> Handler
from pvl.verkko import hosts

# index page here :)
from pvl.verkko import web
class Index (web.Handler) :
    def render (self) :
        html = web.html

        return (
            html.ul(
                html.li(
                    "DHCP Hosts",
                    html.ul(
                        html.li(html.a(href=self.url(hosts.ListHandler, **opts))(title)) for title, opts in hosts.ListHandler.VIEWS
                    )
                ),
            )
        )

urls = Map((
    rule('/',                       Index),
    rule('/hosts/',                 hosts.ListHandler),
    rule('/hosts/<int:id>',         hosts.ItemHandler),
))