durusmail: quixote-users: small proposition for _q_lookup
small proposition for _q_lookup
2005-07-20
2005-07-20
2005-07-20
2005-07-20
2005-07-20
small proposition for _q_lookup
David Binger
2005-07-20
On Jul 20, 2005, at 3:38 PM, Shahms King wrote:


> |   obj = self._q_lookup(component, *path)
>
> That would only work if '*path' had exactly the correct number of
> components, no more no less, which is probably not what you'd want.

I was thinking that the _q_lookup, for this particular Directory,
would end in a *arg.

The bottom line is that this behavior is easy to have in quixote
if you override the _q_traverse() of your directory.  That method gets
the path, and you can do whatever you want with it to make
a response.

>
> Probably something closer to:
>
> argspec = inspect.getargspec(self._q_lookup)
> if argspec[1]: # if _q_lookup accepts a variable argument list
> ~  obj = self._q_lookup(component, *path)
> else: # pass component + as much of path as possible
> ~  obj = self._q_lookup(component, *path[:len(argspec[0]) - 2])

The other problem is that the _q_traverse would need to be change
to consume exactly the right number of components from the path.

reply