Skip to content
Snippets Groups Projects
Commit c13ee360 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Prevent property deprecation warnings when unpickling options

parent 73640ae4
No related branches found
No related tags found
No related merge requests found
......@@ -127,7 +127,8 @@ class Configurable(object):
'_name', # the (unqualified) component name
'_inSetDefaults', # currently setting default values
'_initok', # used to enforce base class init
'_setupok' # for debugging purposes (temporary)
'_setupok', # for debugging purposes (temporary)
'_unpickling', # flag for actions done during unpickling
)
allConfigurables = {} # just names would do, but currently refs to the actual
......@@ -327,6 +328,9 @@ class Configurable(object):
# for debugging purposes (temporary)
self._setupok = False
# used to prevent spurious deprecation warnings when unpickling
self._unpickling = False
# pickle support
def __getstate__(self):
dict = {}
......@@ -346,9 +350,18 @@ class Configurable(object):
def __setstate__(self, dict):
self._initok = True
for n, v in dict.items():
setattr(self, n, v)
return
from contextlib import contextmanager
@contextmanager
def unpickling():
try:
self._unpickling = True
yield
finally:
self._unpickling = False
with unpickling():
for n, v in dict.items():
setattr(self, n, v)
# to allow a few basic sanity checks, as well as nice syntax
def __len__(self):
......
......@@ -105,7 +105,7 @@ class PropertyProxy(object):
def __set__(self, obj, value):
# check if deprecated
if self.deprecated:
if self.deprecated and not obj._unpickling:
log.warning('Property %s is deprecated: %s',
self.fullPropertyName(obj), self.__doc__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment