Skip to content

Commit

Permalink
Moved dispatch examples to the template.
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Jan 7, 2012
1 parent fdd3d5d commit 828d102
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
15 changes: 0 additions & 15 deletions web/ext/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ def prepare(self, context):
def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
Generally called in series, like:
dispatch(context, '/', RootController, False)
dispatch(context, '', RootController.__call__, True)
dispatch(context, '/', RootController, False)
dispatch(context, 'admin', AdminController, False)
dispatch(context, 'user', UsersController, False)
dispatch(context, '27', UserController(27), False)
dispatch(context, 'modify', UserController(27).modify, True)
dispatch(context, '/', AssetController, False)
dispatch(context, 'company/about/staff', PageController, False)
dispatch(context, 'view:page', PageController.page, True)
The base extension uses this to maintain the "current url".
"""
context.path.append(handler)
Expand Down
21 changes: 21 additions & 0 deletions web/ext/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ def dispatch(self, context, consumed, handler, is_endpoint):
The @consumed@ argument is a Path object containing one or more path elements.
The @handler@ argument is the literal object that was selected to process the consumed elements.
The @is_endpoint@ argument is @True@ if there will be no futher dispatch.
Generally called in series, like:
# Index method example.
dispatch(context, '/', RootController, False)
dispatch(context, '', RootController.__call__, True)
# Data-based example.
dispatch(context, '/', RootController, False)
dispatch(context, 'admin', AdminController, False)
dispatch(context, 'user', UsersController, False)
dispatch(context, '27', UserController(27), False)
dispatch(context, 'modify', UserController(27).modify, True)
# Contentment example.
dispatch(context, '/', AssetController, False)
dispatch(context, 'company/about/staff', PageController, False)
dispatch(context, 'view:page', PageController.page, True)
# Route example.
dispatch(context, '/admin/user/27/modify', modify_user, True)
"""

pass
Expand Down

0 comments on commit 828d102

Please sign in to comment.