durusmail: quixote-users: Traversing objects without using _q_lookup
Traversing objects without using _q_lookup
2003-10-03
2003-10-03
Traversing objects without using _q_lookup
Neil Schemenauer
2003-10-03
On Fri, Oct 03, 2003 at 09:37:23AM -0400, Merrell, Brian L. wrote:
> Is is possible to traverse objects without using_q_lookup?

Yes and no.  You can use things like properties and __getattr__ to
dynamically create attributes but the names still have to be in
_q_exports.  _q_lookup is special because it doesn't require the
name to be in _q_exports.

> The demo and documentation of _q_lookup seems geared towards
> instantiating a single glass with a given "component" instead of
> choosing a class to instantiate (with nothing passed to __init__).
> It appears if I use _q_lookup I would have to put a big case
> statement?  Is there a better way?

_q_lookup is really very flexible.  You can pass arguments to
__init__ if you want.  If you don't want a big case statement use
dictionaries.  We do that all the time.  A common pattern is to look
up an object in a dictionary using the component as a key and then
return a UI object that wraps the real object.

> Ideally I would just put the object class into _q_index and it
> would be instantiated and traversal would continue but I can't
> seem to get it to work.

Sorry, it's not clear to me what you want to do.

  Neil

reply