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
Shahms King
2005-07-20
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Binger wrote:
|
| On Jul 20, 2005, at 12:18 PM, vincent delft wrote:
|
|>
|> Why not having the possibility to split the path into
|> several variables ?
|>
|> Would it be difficult to have such in Quixote ?
|
|
| One way to do this is to override the _q_traverse and have
| it call your _q_lookup the way you want, instead of just
| passing the first component on the rest of the path.
|
| Maybe, in _q_traverse(), you would want
|
|   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.

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])

There are still a few cases not handled by the above, but it will handle
the case where you have "sub-directories" beyond the 3 date components
from the example.

- --
Shahms E. King 
Multnomah ESD

Public Key:
http://shahms.mesd.k12.or.us/~sking/shahms.asc
Fingerprint:
1612 054B CE92 8770 F1EA  AB1B FEAB 3636 45B2 D75B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFC3qhF/qs2NkWy11sRAkwIAKDJcjfQ0QnWmQjM7BUVER2apHVIMQCgxVgA
7ankCoS4zqWNUHqAk62GzR0=
=R7HE
-----END PGP SIGNATURE-----
reply