Skip to content

Instantly share code, notes, and snippets.

@sma
Created April 30, 2009 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sma/104618 to your computer and use it in GitHub Desktop.
Save sma/104618 to your computer and use it in GitHub Desktop.
import web
class Page(web.Page):
def create(self):
class ClickCounter(object):
def __init__(self):
self.clicks = 0
counter = ClickCounter()
class Link(web.Link):
def on_click(self):
counter.clicks += 1
link = Link("link1")
class Model(web.Model):
def object(self):
return counter.clicks
self.add(link.add(web.Label("label1", Model())))
html = """<a href="#" web:id="link1">clicked <span web:id="label1">...</span> times</a>"""
web.start(Page)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment