Answer the question
In order to leave comments, you need to log in
Why does data remain after creating a new object?
I am using Tornado version 5 and Python 3.6
. There is a Tornado handler that looks something like this:
class Cb(TornadoBots):
bot = None
answer = None
data = dict()
@gen.coroutine
def post(self, *args, **kwargs):
bot_name, key = args
...
else:
self.__make_answer()
try:
self.__send_answer()
self.write('ok')
except Exception as e:
print(e)
...
def __make_answer(self):
msg = some_data
self.answer = answer.Vk(self.bot, msg)
if data and self.__check_new_message():
self.answer.handle()
else:
...
def __send_answer(self):
try:
if self.answer and self.answer.data:
return self.answer.send()
except Exception as e:
print(e)
def __prepare_answer(self):
self.data.update({'peer_id': self.message.peer_id})
self.command = self.command(...)
self.command.run()
if self.command.data_type == 'action':
return
if ...:
self.data.update({self.command.data_type: self.command.data})
else:
self.data.update(self.command.data)
if ...:
self.data['message'] = tools.get_message('MAKE_ANSWER_ADD_VIP_EMOJI', {'my': self})
if ...:
self.data['forward_messages'] = ...
if ...:
self.data['keyboard'] = ...
if ...:
self.data['message'] += ...
{"attachment": "photoXXX_XXX,photoYYY_YYY"}
# потому что в методе __prepare_answer self.command.data = "photoXXX_XXX,photoYYY_YYY"
{"message": "Some Text", "attachment": "photoXXX_XXX,photoYYY_YYY"}
# хотя self.command.data = "Some Text"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question