From bec3359069390d865c8ce586e68dd781be2c6ee0 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Wed, 3 Mar 2021 14:35:21 +0100 Subject: [PATCH] fixed bugs from syntax migration - a new wrapper for a read function is not only to be created when the a new read function is in the class dict, but also when it inherited, but not yet wrapped - a proxy class must not call checkProperties --- secop/modules.py | 12 +++++++----- secop/proxy.py | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/secop/modules.py b/secop/modules.py index 6e89030..8df582e 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -89,16 +89,17 @@ class HasAccessibles(HasProperties): if isinstance(pobj, Command): # nothing to do for now continue - rfunc = cls.__dict__.get('read_' + pname, None) + 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 if rfunc_handler: - if rfunc: + if rfunc and not_wrapped: raise ProgrammingError("parameter '%s' can not have a handler " "and read_%s" % (pname, pname)) rfunc = rfunc_handler # create wrapper except when read function is already wrapped - if rfunc is None or getattr(rfunc, '__wrapped__', False) is False: + if rfunc is None or not_wrapped: def wrapped_rfunc(self, pname=pname, rfunc=rfunc): if rfunc: @@ -126,11 +127,12 @@ class HasAccessibles(HasProperties): if not pobj.readonly: wfunc = getattr(cls, 'write_' + pname, None) - if wfunc is None: # ignore the handler, if a write function is present + 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 # create wrapper except when write function is already wrapped - if wfunc is None or getattr(wfunc, '__wrapped__', False) is False: + if wfunc is None or not_wrapped: def wrapped_wfunc(self, value, pname=pname, wfunc=wfunc): self.log.debug("check validity of %s = %r" % (pname, value)) diff --git a/secop/proxy.py b/secop/proxy.py index 7320e82..325091c 100644 --- a/secop/proxy.py +++ b/secop/proxy.py @@ -122,6 +122,8 @@ class ProxyModule(HasIodev, Module): self.announceUpdate(pname, None, readerror) self.announceUpdate('status', newstatus) + def checkProperties(self): + pass # skip class ProxyReadable(ProxyModule, Readable): pass