>> I found something strange with `urwid.command_map`.
>> It's a module given by the file *urwid/command_map.py*
>> and it is also an instance of `urwid.command_map.Command_map`.
>>
>> This introduce a problem with lazy import systems (or lazy import introduce
>> the problem :D), mercurial for instance.
>
> Interesting. I haven't played with lazy importing much, except for what
> django does. What exactly causes the problem?
I don't know exactly why. It seems that doing
>>> from urwid.command_map import CommandMap
is converted to something like:
>>> import urwid.command_map
>>> urwid.command_map.CommandMap
if you want to play with it ::
$ cd /tmp
$ hg init lazy
$ cd lazy
$ cat >> lazy.py << EOF
from mercurial import hg, commands, dispatch, error
def do_it(ui, repo, *pats, **opts):
import cmdmap
ui.write(str(cmdmap.CommandMap))
cmdtable = {"lazy": (do_it,[], "do it"),}
EOF
$ cat >> cmdmap.py << EOF
from urwid.widget import Text
TEXT = Text("")
print TEXT
from urwid.command_map import CommandMap
MAP = CommandMap()
print MAP
EOF
Add `lazy = /tmp/lazy/lazy.py` in your ~/.hgrc (section `[extensions]`).
Then
$ cd /tmp/lazy
$ python cmdmap.py
<Text flow widget ''>
<urwid.command_map.CommandMap instance at 0x2802d40>
$ hg lazy
<Text flow widget ''>
Traceback (most recent call last):
...
TypeError: <unloaded module 'CommandMap'> object is not callable
>> Does this behaviour is really needed ?
> Well it's been that way for a few releases, so changing it will break
> some people's code.
Perhaps adding "CommandMap" to urwid/__init__.py(__all__) should be enough.
> Ian
--
Alain Leufroy
LOGILAB, Paris (France)
http://www.logilab.fr
Informatique scientifique & gestion de connaissances
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid