On Sat, 11 Jul 2015 08:25:35 -0500 "Edward K. Ream" <[email protected]> wrote:
> On Thu, Jul 9, 2015 at 4:11 PM, john lunzer <[email protected]> wrote: > > > Edward/Terry, can you help explain what is happening and what is a > > more Leonic way of dealing with this issue. > > The term is "Leonine" :-) > > It appears that your plugin is trying to "cheat" somehow by not > keeping careful track of commanders. This is likely to cause serious > problems. > > The recommended way of writing plugins is to create a separate > controller instance for each commander. The controller sets self.c > to that commander. The controller handles all and *only *the events > pertaining to the commander. The use case for wanting to know "the commander the user's currently looking at" is an external input to Leo (remote procedure call kind of thing, from leoserver.py or mod_http.py etc.). As long as all your commanders are in the one tabbed ui, the answer is "the commander for whatever tab is currently active", I'm not sure what the path to that is. If there's more than one window open showing commanders, I guess the answer is "the focused one", although it might be that some other app. entirely has focus. Anyway, most of the time Edward's right, each controller can have its own instance of the plugins class. OT: leoserver is broken in Py3 and I don't know how to fix it because sockets aren't my thing, so I'm wondering about replacing it with mod_http.py, as in http://localhost:87e0/exec_code/c.selectPosition(p.next()) or http://localhost:87e0/exec_script//tmp/somescript.py (with proper url encoding of course) there's also https://docs.python.org/3/library/xmlrpc.server.html#module-xmlrpc.server but http gives control to the widest audience, incl. browser integration via javascript. Cheers -Terry > There are many examples of this pattern in leoPlugins.leo. I suggest > you follow the pattern unless there is a strong reason not to do so. > > Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
