Configuration Stored In Backend

Here is a short description of what is needed to know. There is presently some overlap in the "old" vs "new" methods, see for more information at WorkPlace and also here

  • all parameters that are needed after startup of gnumed should be stored in the backend (you can as well store them in a config file, but that way your settings are only found on one machine)

  • if you store them in the backend you can assign a user + workplace + cookie to identify the settings in which the value you stored will apply. Usual design is to hold data for one or more of
    • current_user + current_workplace
    • default_user + current_workplace
    • current_user + default_workplace
    • default_user + default_workplace

The cookie can be used to further refine the applicability of this value and might hold data like patient-id, day of week, etc.

  • there are two convenience methods:
    1. gmCfg.getFirstMatchingDBSet, which will return the first appearance of the parameter in question, descending the above shown list of user/workplace pairs.
    2. gmCfg.setDBParam, which will set the parameter for one user/workplace/cookie set to the specified value. If it didn't exist before, it will create this parameter for you in the backend.

In order to do what you want, just call getFirstMatchingDBSet(option="Demographics.window.column.size") and it will return you the value you set for the current user (if nobody set default values).

If you want to set the value after the user changed the column size, just call setDBParam(user=gmWhoAmI.get_db_account(),option="Demographics.window.column.size", value=newValue) to set the value for the current user and default workplace.

A last word on how to name you config options: you can name your options any way you like. However, it should be somewhat self explaining. Note, too, that the Setup plugin will assume a hierarchy with branches denoted by dots (as in python namespaces). So "Demographics.window.column.size" and "Demographics.window.column.color" will show up in the same branch of the navigation tree. This leads to a easier navigation and cleaner appearance.

For an example how it could look like in python please see gmGuiMain.py, method __set_GUI_size(), this is where we reset the GUI size to the one at the previous shutdown although it may be performing inconsistently on some platforms..

reference: http://lists.gnu.org/archive/html/gnumed-devel/2004-08/msg00063.html

From Karsten, Dec 30 2005

We additionally now have the cCfgSQL methods

.get_by_user() .get_by_workplace()

which get an option without regard for workplace/user respectively. IOW if I want to retrieve an option in which the workplace does not matter (think of a personal color preference for the client) I would use cCfgSQL.get_by_user(option = 'my_color'). Both methods support a default value. If set it is returned if the database does not hold an appropriate value. In that case the default value will also be written to the database for the next time around.
Topic revision: 08 Jul 2009, JamesBusser
 
Download.png
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
Powered by Olark