Hi,
we are trying to setup OX in our environment.
For this we have to create the contextIDs first which I tried to do with Python script.
Basically the script works, but I cannot update an existing record. Could you please help?
The similar steps work for updating users, but here the cntext is different and therefore it fails I think.
I’m afraid that I need another approach here, but don’t know what.
Script basically looks like:
from univention.udm import UDM
oxcts=UDM.admin().version(2).get('oxmail/oxcontext')
for i in oxcts.search('name=Context_ToUpdate'):
... obj.position=obj.position
... obj.props.contextid='88456'
... obj.save()
…
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 176, in save
self._copy_to_udm_obj()
File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 367, in _copy_to_udm_obj
self._orig_udm_object[k] = new_val2
File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 400, in __setitem__
raise univention.admin.uexceptions.valueMayNotChange(_('key=%(key)s old=%(old)s new=%(new)s') % {'key': key, 'old': self[key], 'new': value}, property=key)
univention.admin.uexceptions.valueMayNotChange: Value may not change: key=contextid old=88016 new=88456.
>>> oxobj=oxc.get_by_id('Context_ToUpdate')
>>> oxobj.props.contextid=88456
>>> oxobj.save()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 176, in save
self._copy_to_udm_obj()
File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 367, in _copy_to_udm_obj
self._orig_udm_object[k] = new_val2
File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 400, in __setitem__
raise univention.admin.uexceptions.valueMayNotChange(_('key=%(key)s old=%(old)s new=%(new)s') % {'key': key, 'old': self[key], 'new': value}, property=key)
univention.admin.uexceptions.valueMayNotChange: Value may not change: key=contextid old=88016 new=88456.
Thanks for help in advance,
Michael