def post(self): if self.get_argument('recipient_ids'): recipient_ids = map(int, self.get_argument('recipeint_ids', '').split(',')) else: recipient_ids = db.ids_from_emails(self.get_argument('recipient_emails','').split(',')) message_id = db.create_message( sender_id=self.get_user_id(), recipient_ids=recipient_ids, public=(True if self.get_argument('public') == 'true' else False), content=self.get_argument('content'), visible_on=int(self.get_argument('visible_on'))) self.write({'message_id':message_id})
def mock_message(): message_content = random_string(10000) with mock_user() as sender: with mock_user() as recipient: message_id = db.create_message( sender_id=sender['id'], recipient_ids=[recipient['id']], public=False, content=message_content, visible_on=int(random.random() * time.time() + time.time())) try: yield dict( message_id=message_id, message_content=message_content, sender_id=sender['id'], recipient_id=recipient['id']) finally: db.delete_message(message_id)