The 20 Minutes Wiki tutorial is a good example about using _default (http://www.turbogears.org/2.1/docs/main/Wiki20/wiki20.html) but we indeed miss an example for _lookup.
On Sat, Mar 17, 2012 at 12:51 PM, Moritz Schlarb <[email protected]> wrote: > Hey Mengu, thanks for your examples, > > I just ran into the same problem as you and your solutions really helped me > out! > > Best wishes, > > Moritz > > PS: Michael, I think it would be very nice to have this example somewhere in > the TG docs, wouldn't it? > > Am Dienstag, 27. Dezember 2011 02:18:40 UTC+1 schrieb Mengu: >> >> hi michael, >> >> thank you very much for your answer. after reading your post, i did >> dive into the source files under tg/controllers and the documents. >> your post and the >> http://www.turbogears.org/2.1/docs/main/TGControllers.html >> page was very helpful. >> >> for future references if anyone needs, here is how i am using nested >> routes with TG 2.1.4 -as it's the current version right now-: >> >> this is an exempt of my DocumentsController class: >> http://pastie.org/private/1vdjcqo2lbdj6p3zja7a >> >> and this is my PageController class: >> http://pastie.org/private/wleeeoph90geuly2bdh1g >> >> thanks again. >> >> On 26 Aralık, 17:51, Michael Pedersen <[email protected]> wrote: >> > 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 view this discussion on the web visit > https://groups.google.com/d/msg/turbogears/-/XMdj5m7UUo0J. > > 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. -- 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.

