tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/4936-request-pass-handleevent-cleanup-unload-methods-through-to-python-extensions-from-the-pythonextension-containerInfinite Kind: Discussion 2021-03-22T10:12:18Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/490612912021-02-28T12:09:42Z2021-02-28T12:09:42ZREQUEST: Pass .handleEvent() .cleanup() .unload() methods through to Python extensions from the PythonExtension container<div><p>I would like to get my Python extensions operating properly, like Java extensions. Unfortunately, there are some methods that don't reach the Py extension class due to the implementation within Moneydance. When a Py Extension is loaded, the Py Interpreter is invoked (of course), and this Python Interpreter Instance (PyII) is registered as the Moneydance extension. This PyII maintains a reference to the actual Python extension class that the user/script defined and PyII calls this when necessary.</p>
<p>Hence:<br>
- Java Extension: Extension Container -> Java Extension Class(and its methods) - Python Extension: Extension Container(Py) -> Python Interpreter Instance(PyII) -> Py Extension(and its methods).</p>
<p>Thus, PyII is 'blocking' certain things....</p>
<p>Thankfully, PyII does pass through .invoke() so Py extensions can handle .showURL() calls. This is so the "menu" method works.</p>
<p>But the following are not passed through:<br>
.handleEvent() .cleanup() .unload()</p>
<p>Please can the PythonExtension class be tweaked to pass through these methods(), the same as .invoke() to allow Py extensions to:<br>
- Properly handle MD events - Unload properly when uninstalled.</p>
<p>On the latter point, the effect of a Py extension uninstall is that the PyII gets killed, but the underlying Py extension is still operating in memory (until MD restart)..</p>
<p>Many thanks!!</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490612912021-03-20T12:36:31Z2021-03-20T12:36:31ZREQUEST: Pass .handleEvent() .cleanup() .unload() methods through to Python extensions from the PythonExtension container<div><p>This should be in build 3055. I will test and advise..</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/490612912021-03-22T10:12:11Z2021-03-22T10:12:11ZREQUEST: Pass .handleEvent() .cleanup() .unload() methods through to Python extensions from the PythonExtension container<div><p>These methods are now available in build 3056 onwards - there are two options:</p>
<p>1/ in script_info.dict define {"type" = "method", "method" = "handle_event", "script_file" = "handle_event.py"} for example. The methods are handle_event, invoke, cleanup and unload. Within these method scripts, look for the global variable moneydance_extension_parameter for the passed parameter on invoke and handle_event.</p>
<p>2/ .. or instead define and execute an initialisation script when MD loads by defining the following in script_info.dict. {"type" = "initializer", "script_file" = "scriptname.py"} and within your script, define and execute your ExtensionClass and call the class, setting the global variable moneydance_extension=ExtensionClass(). Within this class define .invoke(), .handle_event(), .cleanup(), unload().</p>
<p>NOTE - I don't think .cleanup() actually is used anywhere in MD...</p>
<p>NOTE - There are some 'older' methods of tricking MD to load a Py Extension, some work, some don't now; contact me if you want further details....</p></div>Stuart Beesley (Mr Toolbox)