fixed bugs from syntax migration

- a new wrapper for a read function is not only to be created when
  the a new read method is in the class dict, but also when
  it is inherited, but not yet wrapped
- a handler must not be ignored, when a write method is inherited
- a proxy class must not call checkProperties

+ remove trailing spaces in tutorial_helevel.rst

Change-Id: I16024c14232ea200db91a1bc07ec23326219ab68
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25093
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
l_samenv 2021-03-03 14:35:21 +01:00 committed by Markus Zolliker
parent 7f22a270e6
commit adc9a6da71
2 changed files with 19 additions and 16 deletions

View File

@ -91,15 +91,16 @@ class HasAccessibles(HasProperties):
continue
rfunc = getattr(cls, 'read_' + pname, None)
rfunc_handler = pobj.handler.get_read_func(cls, pname) if pobj.handler else None
not_wrapped = getattr(rfunc, '__wrapped__', False) is False
wrapped = hasattr(rfunc, '__wrapped__')
if rfunc_handler:
if rfunc and not_wrapped:
if rfunc and not wrapped:
raise ProgrammingError("parameter '%s' can not have a handler "
"and read_%s" % (pname, pname))
rfunc = rfunc_handler
wrapped = False
# create wrapper except when read function is already wrapped
if rfunc is None or not_wrapped:
if not wrapped:
def wrapped_rfunc(self, pname=pname, rfunc=rfunc):
if rfunc:
@ -127,12 +128,14 @@ class HasAccessibles(HasProperties):
if not pobj.readonly:
wfunc = getattr(cls, 'write_' + pname, None)
not_wrapped = getattr(wfunc, '__wrapped__', False) is False
if wfunc is None or not_wrapped: # ignore the handler, if a write function is present
wfunc = pobj.handler.get_write_func(pname) if pobj.handler else None
wrapped = hasattr(wfunc, '__wrapped__')
if (wfunc is None or wrapped) and pobj.handler:
# ignore the handler, if a write function is present
wfunc = pobj.handler.get_write_func(pname)
wrapped = False
# create wrapper except when write function is already wrapped
if wfunc is None or not_wrapped:
if not wrapped:
def wrapped_wfunc(self, value, pname=pname, wfunc=wfunc):
self.log.debug("check validity of %s = %r" % (pname, value))