Bug 32544 - UCR Python API for setting and unsetting UCRVs
UCR Python API for setting and unsetting UCRVs
Product: UCS
Classification: Unclassified
Component: UCR
UCS 3.2
All Linux
: P5 normal (vote)
: UCS 3.2
Assigned To: Philipp Hahn
Janek Walkenhorst
: interim-2
: 26819 (view as bug list)
Depends on:
Blocks: 28670 33091
  Show dependency treegraph
Reported: 2013-09-10 17:59 CEST by Philipp Hahn
Modified: 2013-11-19 06:43 CET (History)
2 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted after Product Owner Review:
Ticket number:
Bug group (optional): API change
Max CVSS v3 score:


Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2013-09-10 17:59:31 CEST
UCR currently only exports the command-line functions "handler_set" and "handler_unset" to set and unset UCR variables from within a Python program.
1. handler_set() expects a list of strings of the form "key=value" or "key?value", which is used on the command-line. This is not very pythonic.
2. Combining a set with an unset is currently not possible, which is for example required for re-configuring the network, since the interface.py handler is called after each change and restarts the network.

Add a new Python function to apply changes to UCR:
  ucr_update(ucr, changes):
  Apply all changes to the UCR.
  :ucr: An ConfigRegistry instance, which gets reloaded and saved.
  :changes: A dictionary, which maps UCRV-names to there new value or to None to unset them.
Comment 1 Philipp Hahn univentionstaff 2013-09-13 10:02:47 CEST
Please note: Bug #30128 requests an API change in the last paragraph when unsetting variables, which is implemented: Instead of new_value='' the Python-handler no gets new_value=None in the changes-dictionary.

A review of our standard and the OX/Zarafa handlers shows, that they should be unaffected.

UCR-Scripts are not affected by this change because of Bug #32570.

r43992 | Bug #32544: UCR: Implement new update function
r43991 | Bug #32544: UCR: Refacture common update code
r43990 | Bug #32544: UCR: Refacture common scope parsing
r43989 | Bug #32544: UCR: Simplify replog
r43988 | Bug #32544: UCR: Make scope visible
r43987 | Bug #32544: UCR: Add context wrapper
r43986 | Bug #32544: UCR: Rename 'reg' to 'ucr'
r43985 | Bug #32544: UCR: Minor code cleanup
r43984 | Bug #32544: UCR: Add unit test
r43983 | Bug #28670: UCR: Ignore empty interface settings
r43993 | Bug #32544: UCR: Undo r43985

ChangeLog: r43993
A new function was added to the Python API set and unset &ucsUCRV;s atomically through a disctionary
Comment 2 Philipp Hahn univentionstaff 2013-09-20 08:34:51 CEST
*** Bug 26819 has been marked as a duplicate of this bug. ***
Comment 3 Janek Walkenhorst univentionstaff 2013-09-20 18:11:47 CEST
Review code changes: OK
Test new "update" function: OK
interfaces.py ignores UCRV set to empty string: OK
Changelog: OK
Comment 4 Stefan Gohmann univentionstaff 2013-11-19 06:43:49 CET
UCS 3.2 has been released:

If this error occurs again, please use "Clone This Bug".