Created
April 30, 2009 18:58
-
-
Save sma/104618 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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