On Mon, Apr 27, 2026 at 9:39 PM Arrigo Marchiori <[email protected]> wrote:
> Hello Damjan, All,
>
> this is great!
>
Thank you.
>
> I've played a bit with Python macros and I think I found a small bug.
>
> On Sun, Apr 26, 2026 at 08:36:07PM +0200, Damjan Jovanovic wrote:
>
> [...]
>
> > Most of all, Python scripts can now be edited :-), in a custom little
> > dialog window with "Run", "Save" and "Close" buttons. It all works, they
> > run, they are successfully saved into the document, and can be re-opened.
> > The editing could still be improved a lot, with line numbers, debugging,
> a
> > resizable window and fixed width font, etc., but I don't have time for
> that
> > now, and to be fair, the BeanShell editor isn't much better.
>
> When we click button "Save" of the new Python editing dialog, the code
> is saved, but apparently is not ``active'' yet.
>
> In other words, the ``old'' Python source code is still executed
> whenever we ask to ``run'' a macro.
>
> In order to run the new code, we have to close and reopen the
> _document_.
>
Thank you for testing. You're right, there was a bug there. I think it's
fixed now:
Forget Python modules from the cache after they are saved, so they
get reloaded in the future. This is necessary as getModuleByUrl()'s
self.sfa.getDateTimeModified() returns timestamps with all zeroes
for documents (== ZIP files), breaking the test for whether the
embedded Python file has been changed. Also even if it worked, the
minimum granularity for timestamps in ZIP files is 2 seconds, which
isn't good enough.
Regards
Damjan