core (memory/sqla_mapping): fix legacy pickled values:

folloing packages refactoring, legacy pickled values could not be unpickled (due to use of
old classes). This temporary workaround fix it, but the right thing to do will be to move
from pickle to JSON at some point.
This commit is contained in:
Goffi 2023-06-12 14:57:27 +02:00
commit bf9db70bee

View file

@ -102,7 +102,15 @@ class LegacyPickle(TypeDecorator):
except AttributeError:
pass
# "utf-8" encoding is needed to handle Python 2 pickled data
return pickle.loads(value, encoding="utf-8")
try:
return pickle.loads(value, encoding="utf-8")
except ModuleNotFoundError:
# FIXME: workaround due to package renaming, need to move all pickle code to
# JSON
return pickle.loads(
value.replace(b"sat.plugins", b"libervia.backend.plugins"),
encoding="utf-8"
)
class Json(TypeDecorator):