Created
January 15, 2011 08:00
-
-
Save amcgregor/780774 to your computer and use it in GitHub Desktop.
An example of dynamic dispatch.
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
class User(Controller): | |
def __init__(self, id): | |
self.id = id | |
def index(self): | |
return 'mypkg.views.user', dict(id=self.id) | |
def method(self): | |
return 'mypkg.views.method', dict(id=self.id) | |
class Users(Controller): | |
def index(self): | |
return 'mypkg.views.users', dict(...) | |
def __lookup__(self, id, *remainder, **args): | |
return User(id), remainder | |
class Root(Controller): | |
users = Users() | |
def index(self): | |
return 'mypkg.views.root', dict() | |
def action(self): | |
return ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment