本文整理汇总了Python中r2.models.account.Account._byID36方法的典型用法代码示例。如果您正苦于以下问题:Python Account._byID36方法的具体用法?Python Account._byID36怎么用?Python Account._byID36使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.account.Account
的用法示例。
在下文中一共展示了Account._byID36方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_valid
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def check_valid(self):
"""Returns boolean indicating whether or not this access token is still valid."""
# Has the token been revoked?
if getattr(self, 'revoked', False):
return False
# Is the OAuth2Client still valid?
try:
client = OAuth2Client._byID(self.client_id)
if getattr(client, 'deleted', False):
raise NotFound
except NotFound:
return False
# Is the user account still valid?
if self.user_id:
try:
account = Account._byID36(self.user_id)
if account._deleted:
raise NotFound
except NotFound:
return False
return True
示例2: revoke
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def revoke(self):
super(OAuth2RefreshToken, self).revoke()
account = Account._byID36(self.user_id)
access_tokens = OAuth2AccessToken._by_user(account)
for token in access_tokens:
if token.refresh_token == self._id:
token.revoke()
示例3: get_editor_accounts
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def get_editor_accounts(self):
editors = self.get_editors()
accounts = [Account._byID36(editor, data=True)
for editor in self.get_editors()]
accounts = [account for account in accounts
if not account._deleted]
return accounts
示例4: check_valid
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def check_valid(self):
if getattr(self, 'revoked', False):
return False
try:
client = OAuth2Client._byID(self.client_id)
if getattr(client, 'deleted', False):
raise NotFound
except AttributeError:
g.log.error("bad token %s: %s", self, self._t)
raise
except NotFound:
return False
if self.user_id:
try:
account = Account._byID36(self.user_id)
if account._deleted:
raise NotFound
except NotFound:
return False
return True
示例5: get_authors
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def get_authors(cls, revisions):
authors = [r._get('author') for r in revisions]
authors = filter(None, authors)
return Account._byID36(authors, data=True)
示例6: get_author
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID36 [as 别名]
def get_author(self):
author = self._get('author')
return Account._byID36(author, data=True) if author else None