Dear Michale Pedersen and Moritz Schlarb,
Thanks for your replies. It helps me to understand TG better.

Regards,
Raj

(^!^)
Raj

On Thu, Jul 9, 2015 at 5:33 PM, Moritz Schlarb <[email protected]> wrote:

> The _default and _lookup methods are explained here:
> http://turbogears.readthedocs.org/en/latest/turbogears/objectdispatch.html
> The difference is basically that _default returns a "page" like normal
> @expose'd
> methods, whereas _lookup returns a new controller object where the
> dispatching
> process continues.
>
> > Michael Pedersen <[email protected]> hat am 9. Juli 2015 um 13:09
> > geschrieben:
> >
> >
> > This comes down to a misunderstanding of what happens with the /
> character
> > in URLs and how to use _lookup. I don't know that I have good examples
> for
> > how to use _lookup, so I can't help there, but the other part I can
> explain:
> >
> > TG separates the URL based on the / character. It goes to the top most
> > controller (RootController), and says "Do you know how to handle /media".
> > The RootController has a MediaController named "media", so it goes to
> that
> > controller and asks about the next item: news. Since that controller has
> a
> > NewsController named "news", it goes to the NewsController and asks it
> how
> > to handle the next part.
> >
> > You have a method named index, so whenever the next part is named
> "index",
> > it passes everything to that method. That covers
> "/index/<value-of-param>"
> > and "index?url=<value-of-param>". If there is nothing after the final /
> TG
> > assumes you want to get the index method called, so uses that method.
> That
> > covers "news/" and even "news?url=<value-of-param>" since there's a
> hidden
> > / between "news" and "?url=" (that's how TG interprets it).
> >
> > The final one, though, doesn't cover any of these cases.
> > "news/<value-of-param>" doesn't actually match anything. NewsController
> is
> > asked "do you have any attribute named <value-of-param>" and it doesn't,
> so
> > it can't process it. It returns a 404. What you would need to do is add a
> > method named _lookup() that would then tell TG that the index method
> knows
> > how to handle <value-of-param>.
> >
> > As I said, I don't have examples to share for this right now, so I can't
> do
> > much to give code. I'm sorry. But at least this provides an explanation
> for
> > what to do next.
> >
> > On Tue, Jul 7, 2015 at 2:08 PM Raj <[email protected]> wrote:
> >
> > > Hi,
> > > I have a TG app with following *controllers*:
> > >
> > >    - RootController
> > >    - MediaController
> > >          - News Controller
> > >
> > > In the RootController i have added subcontroller as *media*
> > > =MediaController()
> > > In MediaController i have added *news*=NewsController()
> > >
> > > NewsController is having an index() method with a parameter named 'url'
> > >
> > > The NewsController()->index() page is displaying when the following
> URLs
> > > are invoked
> > >
> > >    - http://localhost:8080/media/news/
> > >    - http://localhost:8080/media/news/index*/<value-of-url-param>*
> > >    - http://localhost:8080/media/news/index*?url=<value-of-url-param>*
> > >    - http://localhost:8080/media/news*?url=<value-of-url-param>*
> > >
> > > But the following URL shows a* 404 error*
> > >
> > >    - http://localhost:8080/media/news*/<value-of-url-param>*
> > >
> > > I am expecting *this should display the same result* as of the URL
> > > http://localhost:8080/media/news*/index/<value-of-url-param>*
> > > What is happening while removing *index *from URL?
> > >
> > > What is the solution?
> > >
> > > Regards,
> > > Raj
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "TurboGears" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > > email to [email protected].
> > > To post to this group, send email to [email protected].
> > > Visit this group at http://groups.google.com/group/turbogears.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "TurboGears" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/turbogears.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "TurboGears" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/turbogears/ek1z85Nm5rA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to