本文整理汇总了Python中pdoauth.models.User.User.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python User.subscribe方法的具体用法?Python User.subscribe怎么用?Python User.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdoauth.models.User.User
的用法示例。
在下文中一共展示了User.subscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import subscribe [as 别名]
@classmethod
def new(cls, user, name, assurer, timestamp = None):
if timestamp is None:
timestamp = time.time()
assurance = cls(user, name, assurer, timestamp)
assurance.save()
return assurance
def __repr__(self):
return "Assurance({0},{1},{2},{3})".format(self.user, self.name, self.assurer, self.timestamp)
@classmethod
def removeAllForUser(cls, user):
instances = cls.query.filter_by(user=user).all()
for instance in instances:
instance.rm()
@classmethod
def getStats(klass):
assuranceStats = dict()
assurances = klass.query.with_entities(Assurance.name).add_column(func.count(klass.name)).group_by(klass.name).all()
for name, value in assurances:
assuranceStats[name] = value
return assuranceStats
User.subscribe(Assurance.removeAllForUser, "pre_rm")
示例2: deleteExpired
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import subscribe [as 别名]
def deleteExpired(cls, credType):
now = time.time()
creds = Credential.query.filter_by(credentialType=credType).all()
for c in creds:
if c.getExpirationTime() < now:
c.rm()
def __repr__(self, *args, **kwargs):
return "Credential(user={0.user.email},credentialType={0.credentialType},identifier={0.identifier},secret={0.secret})".format(self)
@classmethod
def getByUser_as_dictlist(cls, user):
l = []
creds = Credential.query.filter_by(user=user).all()
for cred in creds:
l.append(dict(
credentialType = cred.credentialType,
identifier = cred.identifier
))
return l
@classmethod
def removeAllForUser(cls, user):
creds = Credential.query.filter_by(user=user).all()
for cred in creds:
cred.rm()
User.subscribe(Credential.removeAllForUser, "pre_rm")