本文整理汇总了Python中the_tale.common.postponed_tasks.PostponedTaskPrototype.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.get_by_id方法的具体用法?Python PostponedTaskPrototype.get_by_id怎么用?Python PostponedTaskPrototype.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.common.postponed_tasks.PostponedTaskPrototype
的用法示例。
在下文中一共展示了PostponedTaskPrototype.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_registration
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import get_by_id [as 别名]
def handle_registration(self, request):
if not request.user.is_anonymous():
return HANDLE_REGISTRATION_RESULT.NOT_ANONYMOUS
if accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY not in request.session:
return HANDLE_REGISTRATION_RESULT.NO_TASK_ID
task_id = request.session[accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY]
task = PostponedTaskPrototype.get_by_id(task_id)
if task is None:
return HANDLE_REGISTRATION_RESULT.TASK_NOT_FOUND
if not task.state.is_processed:
return HANDLE_REGISTRATION_RESULT.TASK_NOT_PROCESSED
login_user(request, nick=task.internal_logic.account.nick, password=accounts_settings.FAST_REGISTRATION_USER_PASSWORD)
return HANDLE_REGISTRATION_RESULT.USER_LOGINED
示例2: fast
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import get_by_id [as 别名]
def fast(self):
if self.account.is_authenticated():
return self.json_error('accounts.registration.fast.already_registered', u'Вы уже зарегистрированы')
if conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY in self.request.session:
task_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY]
task = PostponedTaskPrototype.get_by_id(task_id)
if task is not None:
if task.state.is_processed:
return self.json_error('accounts.registration.fast.already_processed', u'Вы уже зарегистрированы, обновите страницу')
if task.state.is_waiting:
return self.json_processing(task.status_url)
# in other case create new task
referer = None
if conf.accounts_settings.SESSION_REGISTRATION_REFERER_KEY in self.request.session:
referer = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_REFERER_KEY]
referral_of_id = None
if conf.accounts_settings.SESSION_REGISTRATION_REFERRAL_KEY in self.request.session:
referral_of_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_REFERRAL_KEY]
action_id = None
if conf.accounts_settings.SESSION_REGISTRATION_ACTION_KEY in self.request.session:
action_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_ACTION_KEY]
registration_task = postponed_tasks.RegistrationTask(account_id=None, referer=referer, referral_of_id=referral_of_id, action_id=action_id)
task = PostponedTaskPrototype.create(registration_task,
live_time=conf.accounts_settings.REGISTRATION_TIMEOUT)
self.request.session[conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY] = task.id
environment.workers.registration.cmd_task(task.id)
return self.json_processing(task.status_url)