-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tom Jenkins wrote:
| Graham Fawcett wrote:
|
| | But having said that, is there anything particularly wrong with this?
| |
| |
| | import foo, bar, baz
| | import _twenty_foo, _twelve_bar, _shebang
| |
| |
| | _q_exports = ['foo', 'bar', 'baz']
| |
| | _other_exports = {
| | '20foo': _twenty_foo,
| | '12bar': _twelve_bar,
| | '#!': _shebang,
| | }
but the following will work
~ import foo, bar, baz
~ import _twenty_foo, _twelve_bar, _shebang
~ _q_exports = ['foo', 'bar', 'baz']
~ _q_map = {
~ '20foo': _twenty_foo,
~ '12bar': _twelve_bar,
~ '#!': _shebang,
~ }
with a 2 line addition in Publisher's _get_component:
if (component != "_q_index" and component not in container._q_exports):
~ # Component is not in exports list.
~ object = None
~ if hasattr(container, "_q_lookup"):
~ object = container._q_lookup(request, component)
~ elif hasattr(container, "_q_getname"):
~ warnings.warn("_q_getname() on %s used; should "
~ "be replaced by _q_lookup()" % type(container))
~ object = container._q_getname(request, component)
+ if object is None and hasattr(container, "_q_map"):
+ object = container._q_map.get(component)
~ if object is None:
~ raise errors.TraversalError(
~ private_msg="object %r has no attribute %r" % (
~ container,
~ component))
I don't know. Just a thought. Not 100% sure I like _q_map as it
doesn't immediate suggest any sort of association between it an
_q_export (which in certain way there is).
I wasn't sure what problem we were solving here that _q_lookup or
_q_resolve (and a dictionary) couldn't do adequately. I guess the only
things are that with _q_lookup you can potentially be hiding your export
in the dictionary and maybe you have other uses for the _q_lookup?? And
with the _q_resolve you'd have to duplicate the keys in the dictionary
in the _q_exports.
Is that enough?
- --
Tom Jenkins
devIS - Development Infostructure
http://www.devis.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0-nr2 (Windows XP)
Comment: Using GnuPG with MultiZilla - http://enigmail.mozdev.org
iD8DBQFAdDv1V7Yk9/McDYURApsSAJ4yyw3far4ko97kqnVfaGDoUuz9PgCgujh5
5MW2ZKGyQ6yQxwBajEm+jGs=
=yHo1
-----END PGP SIGNATURE-----