On Apr 1, 12:46 pm, "Edward K. Ream" <[EMAIL PROTECTED]> wrote:
> leo.src.leo.run() fails: g.app isn't defined in the plugins. No doubt
> this is a subtle import problem. At least I'm debugging my own
> code :-)
Apparently Python can import leoGlobals twice, resulting in two
entries in sys.modules:
one for leo.src.leoGlobals and one for leoGlobals (!!) Both come from
the same .pyc file.
I put a print statement at the start of leoGlobals.py. Here is part of
the trace:
C:\prog\test>python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import leo
>>> leo.run() # see below
> c:\python25\lib\site-packages\leo\__init__.py(13)run()
<module 'leo.src.leoGlobals' from 'c:\python25\lib\site-packages\leo
\src\leoGlobals.pyc'>
reading settings in C:\python25\lib\site-packages\leo\config
\leoSettings.leo
reading settings in C:\Documents and Settings\HP_Administrator\My
Documents\Edward\myLeoSettings.leo
reading C:\Documents and Settings\HP_Administrator\My Documents\Edward
\.leoRecentFiles.txt
@enabled-plugins found in myLeoSettings.leo
<module 'leoGlobals' from 'C:\python25\lib\site-packages\leo\src
\leoGlobals.pyc'>
This causes havoc because g.app is not properly inited after the
second import.
BTW, I defined the following run method in leo/__init__.py:
def run(*args,**keys):
from leo.src.leo import run
run(*args,**keys)
This allows users to do leo.run() rather than leo.src.leo.run(). This
convenience function is not the problem: the same failure happens if
the user invokes leo.src.leo.run()
I'm not sure what the solution is. Possibly all Leo imports will have
to be changed from:
import leoX
to
import leo.core.x.
It's becoming clear that this is a 'project'. It might be possible to
play games with Python's imp module, but usually I try to avoid such
tricky code.
Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---