Summary: | Make the worksheet path available to backends (enhancement proposal with patch) | ||
---|---|---|---|
Product: | [Applications] cantor | Reporter: | matpen |
Component: | general | Assignee: | Alexander Semke <alexander.semke> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | alexander.semke, alexanderrieder, matpen |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | All | ||
Latest Commit: | https://commits.kde.org/cantor/211c00896d3f64e3761832d3ab2e72cf28cbfc0d | Version Fixed In: | 18.04.1 |
Sentry Crash Report: | |||
Attachments: | Allows to send the current worksheet path to backends on load/save. |
Description
matpen
2016-02-04 11:05:35 UTC
Created attachment 97006 [details]
Allows to send the current worksheet path to backends on load/save.
The patch introduces the "StoreWorksheetPath" backend capability. Backends with this capability state their interest in the current worksheet path.
If a backend has this capability, the worksheets communicates its path to the session whenever it changes (on load/save). The backend can then act upon the change.
The patch further implements this ability for the sage backend: when the path changes, it is stored into the "__file__" variable. This variable usually set by importing the "os" package. However, since sage is run in a server session, this variable is always unset within cantor.
What is the exact use case you need this for? (In reply to Alexander Semke from comment #2) > What is the exact use case you need this for? My exact use case is a scientific application in C++, for which we require mathematical algorithms. These are prepared in cantor with sage backend. The resulting formulae are quite complicated, and we therefore use sage's codegen to generate C++ code (instead of manually translating the code). Once the code is generated, the C++ files are automatically updated by python/sage, thus skipping another manual step. Since the absolute location of the C++ files cannot be hardcoded in the sage script (as it changes when working on different machines), it has to be recalculated from the relative locations between the cantor worksheet and the C++ files. In the same spirit, anything that requires a file path is forced to use absolute paths. One example is including separate sage scripts from a personal library. Git commit 976dbf7727389d022b8d884854ab2d3f8d008b50 by Alexander Semke. Committed on 30/04/2018 at 07:12. Pushed by asemke into branch 'master'. Make the path of the currently opened project file available in the sage session. FIXED-IN: 18.04.1 M +9 -0 src/backends/sage/sagesession.cpp M +1 -0 src/backends/sage/sagesession.h M +6 -0 src/lib/session.cpp M +10 -0 src/lib/session.h M +5 -1 src/worksheet.cpp https://commits.kde.org/cantor/976dbf7727389d022b8d884854ab2d3f8d008b50 Git commit 211c00896d3f64e3761832d3ab2e72cf28cbfc0d by Alexander Semke. Committed on 07/05/2018 at 20:45. Pushed by asemke into branch 'Applications/18.04'. Make the path of the currently opened project file available in the sage session. FIXED-IN: 18.04.1 M +9 -0 src/backends/sage/sagesession.cpp M +1 -0 src/backends/sage/sagesession.h M +6 -0 src/lib/session.cpp M +10 -0 src/lib/session.h M +5 -1 src/worksheet.cpp https://commits.kde.org/cantor/211c00896d3f64e3761832d3ab2e72cf28cbfc0d |