On Sun, Feb 12, 2012 at 3:19 PM, Edward K. Ream <[email protected]> wrote:
>> The next step will be to discover what kind of data
>> leoFileCommands.getLeoFile presently sets in the commander.
>
> A little experimentation revealed that the proper question is what
> kind of dummy commander is required.
Using a dummy commander probably creates more work than is necessary.
The following puts up an empty window.
c,frame = g.app.newLeoCommanderAndFrame(
fileName=fn,gui=g.app.gui)
fc = c.fileCommands
ok,ratio = fc.getLeoFile(theFile,fn,readAtFileNodesFlag=False,silent=False)
This topic is enough to make my head explode, but I think Leo can load
a .leo file in a single pass, using a single commander, provided that
we adopt the following rule:
** The startup code should use settings only in the finishCreate methods. **
There are several violations of this rule at present, including the following::
1. fc.getLeoFile contains::
if c.config.getBool('check_outline_after_read'):
c.checkOutline(event=None,verbose=True,unittest=False,full=True)
It will not be a big problem to honor this setting (say in
g.openWithFileName) after config settings have been handled.
2. g.openWrapperLeoFile contains:
if c.config.getBool('use_chapters') and c.chapterController:
c.chapterController.finishCreate()
This should be even easier to deal with, as follows...
At present, several finishCreate methods call other finishCreate
methods. It be better to have a single method,
LoadManager.finishCreate, be responsible for calling all other
finishCreate methods. This removes tricky order considerations from
the subsidiary finishCreate methods, and puts them in a single place
where the order is made completely explicit.
lm.finishCreate will be called after all settings have been handled,
so all the other finishCreate methods can use settings.
To make this as painless as possible, I plan to retain the overall
loading structure. This means retaining the names and calling
sequences of load-related methods . In particular, I want to retain
the signatures of the following methods:
g.openWithFileName
g.app.newLeoCommanderAndFrame
fc.getLeoFile
fc.open
The signature of g.openWithFileName will remain unchanged, but its
entire code will probably move to the LoadManager.
The status of the following settings methods is unclear. Their
signatures may change, or perhaps they may disappear completely.
g.app.config.openSettingsFile
g.app.config.updateSettings
===== Conclusions
We are getting close to a strategy. The "use no settings until
finishCreate time" rule is easy to understand and should be relatively
easy to enforce. Indeed a single assert in the config code could
ensure that no calls to it are made until a LoadManager flag is set.
This strategy is still provisional. More experimentation is required,
but I am beginning to have hopes that the new loading code will work.
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.