durusmail: quixote-users: [patch] _q_import
[patch] _q_import
[patch] _q_import
2002-12-02
2002-12-03
2002-12-03
2002-12-04
2002-12-07
2002-12-07
2002-12-09
2002-12-09
2002-12-05
[patch] _q_import
Jonathan Corbet
2002-12-03
> Hmmmm.  Here's an alternative patch that just refactors
> Publisher.get_component() a bit (untested):
[...]
> With this, you could just override _import_submodule() and come up with
> sub-module names in your own way.  Or add support for _q_import without
> the indentation going crazy.

Hmm...I think I like my way better.  The publisher really knows very little
about the tree(s) it is exporting, and, I think, it should be that way.
_q_import lets you set up a different regime in different places, and to
put the import logic right with the part of the namespace that it affects.
I would farm out _q_import for the same reason that _q_getname is not
implemented within the publisher itself.

Of course, overriding _import_submodule() myself to add the _q_import
functionality is certainly a workable solution.

As for the indentation...you could consider simply getting rid of the
current _get_module() implementation.  It kind of breaks the Quixote "I
won't guess" rule.  The publisher doesn't know how the namespace is put
together, and, in my case, guesses wrong.

I had even pondered adding a _q_autoload list, and only importing things
found in that list, but I decided that _q_exports is probably sufficient.

Of course, that's just my opinion, which is known to be unreliable...

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net

reply