当前位置: 首页>>代码示例>>Python>>正文


Python User.subscribe方法代码示例

本文整理汇总了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")
开发者ID:Claymanus,项目名称:PDOauth,代码行数:31,代码来源:Assurance.py

示例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")

开发者ID:Claymanus,项目名称:PDOauth,代码行数:31,代码来源:Credential.py


注:本文中的pdoauth.models.User.User.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。