View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002632||FreeCAD||Feature||public||2016-07-22 16:24||2021-02-06 06:32|
|Target Version||0.20||Fixed in Version||0.17|
|Summary||0002632: Improvements to Prefs for Python|
|Description||I'd like to see a couple improvements to the preference parameter access methods for python.|
I'm planning to save collections of tool data into the preference system to make them available between FreeCAD documents. The configuration of this data can represent a significant effort on the part of the user.
First, I'd like to be able to force a write of the parameters to disk immediately instead of waiting for FreeCAD to exit normally. I know this is possible from the Parameters dialog but I don't think it's possible from python.
Second, I'd like to be able to iterate through the keys in a Group.
I think currently the group isn't iterable so I can't retrieve a value without knowing the key in advance.
||Looks like iterating the group is done by Yorik. http://forum.freecadweb.org/viewtopic.php?f=10&t=16669|
@sliptonic is the iterating the group hack documented somewhere ?
> I'd like to be able to force a write of the parameters to disk immediately instead of waiting for FreeCAD to exit normally. I know this is possible from the Parameters dialog but I don't think it's possible from python.
What remains to be done for this feature?
>@sliptonic is the iterating the group hack documented somewhere ?
I'm not sure. @yorik might have a better answer.
>What remains to be done for this feature?
prefs are still not persisted to disk until FreeCAD exits normally. AFAIK, there's no python function to force and immediate save.
The feature is documented in the source, and therefore in the python console and the API docs.
About implementing a function that saves the parameters, that should be possible, indeed the parameter editor does that.
@sliptonic a workaround that I used in Draft is to keep a copy of the preference value you want, somewhere in a place where it will be kept alive, and update the preference value whenever it changes.
||@yorik Please advise how to proceed with this ticket? Should it be revised? rewritten? split? closed?|
||@sliptonic care to weigh in?|
||I don't plan to do anything more here. We can leave this open in case someone wants to code some kind of "write preferences to disk now" python function. Personally I don't really feel it necessary though, given the method indicated above that I used in Draft...|
I believe we're going to migrate away from storing tools in the user preferences and store them in an external file. This will eliminate my immediate need.
However, I still think this is a deficiency that should be addressed. Anyone writing in Python can set a value in prefs with prefs.SetString() but the assumption then is the value will eventually be persisted to disk on the next normal exit. If FC crashes, this is lost. If a python programmer is writing directly to the preference system, he should be able to force persistence immediately.
For future reference, below is a patch to add a python function to save to disk. But this seems of little use to me... @wmayer might be able to say if there is a specific reason why preferences are saved at freecad exit only?
|2016-07-22 16:24||sliptonic||New Issue|
|2016-10-22 20:33||sliptonic||Note Added: 0007416|
|2017-01-17 04:23||Kunda1||Note Added: 0007830|
|2017-01-17 17:49||sliptonic||Note Added: 0007842|
|2017-05-01 23:20||Kunda1||Tag Attached: python|
|2017-05-01 23:21||Kunda1||Note Added: 0008843|
|2017-05-02 23:39||yorik||Note Added: 0008875|
|2017-10-19 12:42||Kunda1||Tag Attached: documentation|
|2017-10-19 12:43||Kunda1||Tag Attached: split ticket|
|2017-10-19 12:50||Kunda1||Assigned To||=> Kunda1|
|2017-10-19 12:50||Kunda1||Status||new => assigned|
|2017-10-21 21:33||Kunda1||Note Added: 0010336|
|2017-10-21 21:34||Kunda1||Status||assigned => feedback|
|2017-10-22 19:30||Kunda1||Assigned To||Kunda1 =>|
|2017-10-23 13:17||Kunda1||Note Added: 0010341|
|2017-10-23 17:50||yorik||Note Added: 0010343|
|2017-10-23 19:30||sliptonic||Note Added: 0010345|
|2017-10-23 19:30||sliptonic||Status||feedback => new|
|2017-10-23 21:43||yorik||Note Added: 0010346|
|2017-10-25 10:40||wmayer||Status||new => closed|
|2017-10-25 10:40||wmayer||Resolution||open => fixed|
|2017-10-25 10:40||wmayer||Fixed in Version||=> 0.17|
|2017-10-25 10:40||wmayer||Note Added: 0010351|
|2017-10-25 11:49||Kunda1||Tag Detached: split ticket|
|2019-07-29 15:05||Kunda1||Changeset attached||=> FreeCAD master 0ad9436e|
|2021-02-06 06:32||abdullah||Target Version||=> 0.20|