Lines 203-223
if ucr.is_false('repository/online/unmaintained', True):
|
Link Here
|
---|
|
203 |
</example> |
203 |
</example> |
204 |
<para> |
204 |
<para> |
205 |
Modifying variables requires a different approach. |
205 |
Modifying variables requires a different approach. |
206 |
Two functions <function>handler_set()</function> and <function>handler_unset()</function> can be used to set and unset variables. |
206 |
The function <function>ucr_update()</function> should be used to set and unset variables. |
207 |
</para> |
207 |
</para> |
208 |
<example> |
208 |
<example> |
209 |
<title>Changing &ucsUCRV;s in Python</title> |
209 |
<title>Changing &ucsUCRV;s in Python</title> |
210 |
<programlisting><![CDATA[ |
210 |
<programlisting><![CDATA[ |
211 |
from univention.config_registry import handler_set, handler_unset |
211 |
from univention.config_registry.handler import ucr_update |
212 |
handler_set([ |
212 |
ucr_update(ucr, { |
213 |
'foo=bar', |
213 |
'foo': 'bar', |
214 |
'baz=42', |
214 |
'baz': '42', |
215 |
]) |
215 |
'bar': None, |
216 |
handler_unset(['foo', 'bar']) |
216 |
}) |
217 |
]]></programlisting> |
217 |
]]></programlisting> |
218 |
</example> |
218 |
</example> |
219 |
<para> |
219 |
<para> |
220 |
As <function>handler_set()</function> and <function>handler_unset()</function> don't automatically update any instance of <classname>ConfigRegistry</classname>, the <methodname>load()</methodname> method has to be called manually afterwards to reflect the updated values. |
220 |
The function <function>ucr_update()</function> requires an instance of <classname>ConfigRegistry</classname> as its first argument. |
|
|
221 |
The method is guaranteed to be atomic and uses file locking internally to prevent race conditions. |
222 |
</para> |
223 |
<para> |
224 |
The second argument must be a Python dictionary mapping <acronym>UCR</acronym> variable names to their new value. |
225 |
The value must be either a string or <constant>None</constant>, which is used to unset the variable. |
221 |
</para> |
226 |
</para> |
222 |
</section> |
227 |
</section> |
223 |
</section> |
228 |
</section> |