pvl/verkko/urls.py
author Tero Marttila <terom@paivola.fi>
Wed, 10 Oct 2012 23:44:37 +0300
changeset 7 7baf4cccb4a9
parent 5 91970ce3fc6b
child 8 f64c44640b15
permissions -rw-r--r--
move Index to urls; fix self.url(sort=...)
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(
                # TODO: self.url
                html.a(href=self.url(hosts.IndexHandler))("DHCP Hosts"),
            )
        )

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