Univention Bugzilla – Bug 52438
make UCR initialization chainable
Last modified: 2020-11-27 16:13:41 CET
This code can be seen in almost all UCS software: ucr = ConfigRegistry() ucr.load() It'd be shorter to write this instead: ucr = ConfigRegistry().load() For that the univention.config_registry.backend.ConfigRegistry.load() method must simply return 'self'. Apart from slightly shorter code, this is foremost interesting to replace module level execution of I/O code (ucr.load()) with a lazy function: ucr = lazy_object_proxy.Proxy(lambda: ConfigRegistry().load()) The UCS@school lib already uses such a construct for a single, lazily loaded() UCR instance (that is used by most of the UCS@school code). ucs-school-lib/python/models/utils.py:104 The API change is IMHO OK, as I don't expect any code to depend on the old return value of load() to be 'None'.
See Bug #51126 for "Shared lazy-loaded read-only ConfigRegistry singleton"
(In reply to Philipp Hahn from comment #1) > See Bug #51126 for "Shared lazy-loaded read-only ConfigRegistry singleton" Oh… I totally forgot about that. I'll retract this bug in favor of the existing one. *** This bug has been marked as a duplicate of bug 51126 ***