This works - the little client script together with the monkey-patched leoserver was able to transfer an outline from my desktop to the laptop. However, the outline wasn't actually getting inserted into the new outline. I had to actually go through that clipboard to make that happen. I don't understand that, but it seems like a minor matter.
So we have the beginnings of a little system here. More error handling, the complementary save function, and a way to set and track the filename of the file so it can be saved from the remote to the right file on the host: then we'll be in business. What I like about this approach is its basic simplicity. Minor extensions to leoserver, which won't necessarily even require changes to leoserver.py itself, and a user-initiated script or two on the remote computer, nothing too complex, thanks to Felix's work on leoserver. We do need to have the user start the server on the host machine, but we can't avoid that unless we can get Leo to start a server on startup. I don't imagine we really want that, do we? But the user could write a batch file that starts both Leo and the server, with --persist of course. On Sunday, March 13, 2022 at 6:21:36 PM UTC-4 [email protected] wrote: > Continuing the previous discussion (Using a Leo Outline On Another > Computer? <https://groups.google.com/g/leo-editor/c/lbrgq0YBG-0>), we > don't even have to change leoserver. Instead, we can import it and monkey > patch it. Basically, import leo.core.leoserver, and then add the following: > > SetEncoder = leoserver.SetEncoder > InternalServerError = leoserver.InternalServerError > ServerError = leoserver.ServerError > TerminateServer = leoserver.TerminateServer > ServerExternalFilesController = leoserver.ServerExternalFilesController > LeoServer = leoserver.LeoServer > main = leoserver.main > leoserver.wsHost = "10.0.0.58" # If we want to change the default > > def send_outline(self, param): > filename = param.get('path', '') > result = '' > if filename and os.path.exists(filename): > with open(filename, encoding = 'utf-8') as f: > result = f.read() > > data = {"outline": result} > return self._make_response(data) > > LeoServer.send_outline = send_outline > > Of course, we could add other new methods the same way. This approach > works with my little test client. > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/9364abed-92fa-4975-889a-53cf9a456d69n%40googlegroups.com.
