Beispiel #1
0
class SetupLoginTask(CommandParallel):
    def __init__(self, site_id, site_token, hook, user_id=None, user_email=None, lang='en_US'):
        setup_locale(lang)
        self.lang = lang
        self.validate_login = ValidateLoginCall(site_id, site_token, hook, user_id, user_email)
        self.hook = hook
        super(SetupLoginTask, self).__init__(self.validate_login)


    def do_business(self):
        super(SetupLoginTask, self).do_business()
        logging.info('SetupLoginTask do_business')
        if not self.errors:
            self.create_login = CreateLogin(self.validate_login.user, self.validate_login.site, self.hook)
            self.create_login.set_up()
            self.create_login.do_business()
            login = self.create_login.result
            params = {'login_id': str(login.key.id()), 'lang': self.lang}
            logging.info('SetupLoginTask do_business %r' % params)
            self.task = TaskQueueCommand(settings.TASK_HERO, '/task/send_login_email',
                                         params=params, countdown=4)
            self.task.set_up()
            self.task.do_business()
            self.result = login

    def commit(self):
        if not self.errors:
            return to_model_list(self.create_login.commit()) + to_model_list(self.task.commit())
Beispiel #2
0
 def do_business(self):
     super(SetupLoginTask, self).do_business()
     logging.info('SetupLoginTask do_business')
     if not self.errors:
         self.create_login = CreateLogin(self.validate_login.user, self.validate_login.site, self.hook)
         self.create_login.set_up()
         self.create_login.do_business()
         login = self.create_login.result
         params = {'login_id': str(login.key.id()), 'lang': self.lang}
         logging.info('SetupLoginTask do_business %r' % params)
         self.task = TaskQueueCommand(settings.TASK_HERO, '/task/send_login_email',
                                      params=params, countdown=4)
         self.task.set_up()
         self.task.do_business()
         self.result = login
Beispiel #3
0
 def test_queue_creation(self):
     task_obj = Mock()
     task_cls = Mock(return_value=task_obj)
     rpc_mock = Mock()
     queue_obj = Mock()
     queue_cls = Mock(return_value=queue_obj)
     gaeutil.Queue = queue_cls
     gaeutil.taskqueue.create_rpc = Mock(return_value=rpc_mock)
     gaeutil.Task = task_cls
     queue_name = 'foo'
     params = {'param1': 'bar'}
     url = '/mytask'
     cmd = TaskQueueCommand(queue_name, url, params=params)
     cmd.execute()
     task_cls.assert_called_once_with(url=url, params=params)
     queue_obj.add_async.assert_called_once_with(task_obj, rpc=rpc_mock)
     rpc_mock.get_result.assert_called_once_with()
Beispiel #4
0
def contagem(total='0.00', cursor=None):
    busca_cmd = venda_facade.contabilizar_venda_cmd(cursor)
    venda = busca_cmd()
    corpo = render('vendas/email.txt', {'total': total})
    if venda is None:
        logging.info(total)
        mail.send_mail(settings.SENDER_EMAIL, '*****@*****.**',
                       'Contabilização de vendas', corpo)
    else:
        total = Decimal(total)
        total += venda.preco
        cmd = TaskQueueCommand('rapida',
                               to_path(contagem),
                               params={
                                   'total': str(total),
                                   'cursor': busca_cmd.cursor.urlsafe()
                               })
        cmd()