def load_system_data(self, base_model, key): """ Get object's system data from database except base data. Args: base_model: (String) base data's table name. key: (String) object's data key. Returns: None """ # Get models. for data_model in self.get_models(): if data_model == base_model: continue # Get data record. try: fields = WorldData.get_fields(data_model) record = WorldData.get_table_data(data_model, key=key) record = record[0] except Exception as e: logger.log_errmsg("Can not find key %s in %s" % (key, data_model)) continue # Set data. for field_name in fields: setattr(self.system, field_name, getattr(record, field_name))
def get_fields(cls): """ Get table fields. """ return WorldData.get_fields(cls.table_name)