adjust mechanism of write function with iohandler
if a write_<parameter> function is defined and <parameter> has an iohandler, the handlers write function is not called automatically. It has to be called explicitly in the write_<param> function, if needed. reasons: - the previous logic when a wrapped write function is already present, and a handler is defined on the specialized class, did not work, and is not easy to solve properly - it is probably anyway better to call the handlers write function explicitly instead of automatically depending on the return value Change-Id: I04f0849b6cc3fb9979c0f5ac8245a6ab4bf23072 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22565 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -49,9 +49,8 @@ def change_<group>(self, change):
|
||||
# which will be formatted by the handler, or None. The latter is used only in some
|
||||
# special cases, when nothing has to be written.
|
||||
|
||||
A write_<parameter> method may be implemented in addition. In that case, it is executed
|
||||
before change_<group>. write_<parameters> may return None or Done, in these cases
|
||||
change_<group> is not called.
|
||||
A write_<parameter> method may be implemented in addition. In that case, the handlers write
|
||||
method has to be called explicitly int the write_<parameter> method, if needed.
|
||||
"""
|
||||
import re
|
||||
|
||||
@ -263,6 +262,8 @@ class IOHandler(IOHandlerBase):
|
||||
if self._module_class != modclass:
|
||||
raise ProgrammingError("the handler '%s' for '%s.%s' is already used in module '%s'"
|
||||
% (self.group, modclass.__name__, pname, self._module_class.__name__))
|
||||
# self.change might be needed even when get_write_func was not called
|
||||
self.change = getattr(self._module_class, 'change_' + self.group, None)
|
||||
self.parameters.add(pname)
|
||||
self.analyze = getattr(modclass, 'analyze_' + self.group)
|
||||
return self.read
|
||||
@ -295,7 +296,6 @@ class IOHandler(IOHandlerBase):
|
||||
If pre_wfunc is given, it is to be called before change_<group>.
|
||||
May be overriden to return None, if not used
|
||||
"""
|
||||
self.change = getattr(self._module_class, 'change_' + self.group)
|
||||
|
||||
def wfunc(module, value, hdl=self, pname=pname):
|
||||
hdl.write(module, pname, value)
|
||||
|
Reference in New Issue
Block a user