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
David Ascher
2002-01-25
Here's a slightly different version of Neil's code which makes a bit
more sense to me:

def _q_getname(self, component):
    print 'global getname', component
    return Folder(component)

class Folder:
    _q_exports = []
    def __init__(self, path=''):
        print 'init', path
        self._path = path
    def _q_getname(self, request, component):
        print 'getname', component
        return Folder('.'.join((self._path, component)))
    def __call__(self, request):
        print 'call', self._path
        return 'call ' + self._path
    def _q_index(self, request):
        print 'index', self._path
        return 'index ' + self._path

looking up /a/b/c prints:

global getname a
init a
getname b
init a.b
getname c
init a.b.c
call a.b.c

and looking up a/b/c/ prints:

global getname a
init a
getname b
init a.b
getname c
init a.b.c
index a.b.c

in the debug log, all of which make me happy and contented.

Now, the only difference with Neil's code is that I'm not using
_q_getname to return "self", and instead use _q_getname to return a
child folder.  This seems more 'right' to me.  Am I missing a greater
truth about web object modeling?

--david


reply