Возникает следующая ошибка:
NameError: name 'Report_query' is not defined
И все было бы ясно, если бы я не объявил ее как глобальную, но я это сделал в функции
class ExcelReportsManager:
Report_query = Queue()
@staticmethod
def get_storages_report(city_id, employee_id):
res = []
storages = Storage.query.filter(Storage.deleted.is_(False)).all() if not city_id else \
Storage.query.filter(and_(Storage.deleted.is_(False), Storage.city_id == city_id)).all()
for storage in storages:
free_space = 0
filled_num = 0
for cell in storage.cells:
filled_num += cell.filled
free_space += cell.capacity - cell.filled
storage_info = {'Город': storage.city.city,
'Склад': storage.name,
'Адрес склада': storage.address,
'Свободно': free_space,
'Занято': filled_num
}
res.append(storage_info)
ordered_list = ['Город', 'Склад', 'Адрес склада', 'Свободно', 'Занято']
global Report_query
Report_query.put(ExcelReportsManager.__generate_xlsx(ordered_list, res, employee_id))
В чем может быть ошибка?
global
работает совсем не так как вы думаете. Пространство имён класса это не глобальное пространство имён