durusmail: quixote-users: Question about _q_getname
Question about _q_getname
2002-01-24
2002-01-24
2002-01-24
2002-01-24
2002-01-25
2002-01-25
Question about _q_getname
Neil Schemenauer
2002-01-24
Here's a bit of code that should clear things up.

    class Folder:

        _q_exports = []

        def _q_getname(self, request, component):
            print "_q_getname", component
            return self

        def _q_index(self, request):
            return "index"

        def __call__(self, request):
            return "call"

    def _q_getname(request, component):
        return Folder()._q_getname(request, component)

Accessing the path /a/b/c will print in the debug log:

    _q_getname a
    _q_getname b
    _q_getname c

and return the text "call".  Accessing /a/b/c/ (note the trailing slash)
will print the same thing in the debug log but return "index" as the
text.  /a/b/c/ is the same as "/a/b/c/_q_index".

Now, I think the reason you are getting "a b a b" is because the
FIX_TRAILING_SLASH option is turned on, your Folder object is not
callable and you are actually accessing "/a/b".  When Quixote is done
traversing that path it ends up with a Folder instance.  Since that
object is not callable Quixote helpfully issues a redirect to "/a/b/".
While you're in development I would suggest turning the
FIX_TRAILING_SLASH option off.

  Neil


reply