On Sun, Dec 25, 2011 at 12:02 PM, Mengu <[email protected]> wrote:

> i have a conceptual question on routes. in rails we would have routes
> and nested routes. for example a document has many pages and i could
> set up routes like "/documents/:id/pages", "/documents/:id/pages/[new|
> create|edit|update|destroy]. is this possible with turbogears?


Well, the preferred mechanism in TG is to use Object Dispatch. So, it
functions differently. Despite it working differently, yes, it is possible.

Your controller has two methods to assist with this:

_default(): This will be called whenever the index method would be called,
but there is no index method.
_lookup(): This will be called when your controller is responsible for
handling the URL, but no match could be found.

So, for examples (we assume a root controller that *only* has _default and
_lookup defined, for sake of simplified examples):

URL: http://example.com/
method: _default

URL: http://example.com/documents/idnum/pages
method: _lookup

The pattern can be nested deeply, as well, allowing you to have a
controller mounted at documents, which would then _lookup the idnum and act
appropriately. It could even dispatch the control down to a further nested
subcontroller for more localized processing.

-- 
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: [email protected] -- Twitter: pedersentg

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to