My app runs on Windows and I am trying to configure it for Linux.
I get the following AttributeError
:
Preferences instances has no attribute 'self.setattr'
class Preferences:
def __init__(self):
"""
Default preferences are imported from parameters
file at each creation of an object.
The database default is not automatically
updated (file schema.sql). On Preferences parameters change,
schema.sql should be changed accordingly.
"""
with open(os.path.join(APP_ROOT, 'parameters.json')) as parameters:
json_data = json.loads(parameters.read())
# for each att(ribute) from preference file,
# create an attribute in Preferences Object
# which is a Preference object
for att in json_data['preferences']:
self.__setattr__(
att,
Preference(
**{label: json_data['preferences'][att][label] for label in json_data['preferences'][att]}))
Your class literally doesn't have a __setattr__
method. What you want to do is
setattr(self, name, value)
instead of
self.__setattr__(name, value)