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


Python LastModified.get方法代码示例

本文整理汇总了Python中r2.models.last_modified.LastModified.get方法的典型用法代码示例。如果您正苦于以下问题:Python LastModified.get方法的具体用法?Python LastModified.get怎么用?Python LastModified.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在r2.models.last_modified.LastModified的用法示例。


在下文中一共展示了LastModified.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_last_visit

# 需要导入模块: from r2.models.last_modified import LastModified [as 别名]
# 或者: from r2.models.last_modified.LastModified import get [as 别名]
    def update_last_visit(self, current_time):
        from admintools import apply_updates

        apply_updates(self)

        prev_visit = LastModified.get(self._fullname, "Visit")
        if prev_visit and current_time - prev_visit < timedelta(days=1):
            return

        g.log.debug("Updating last visit for %s from %s to %s" % (self.name, prev_visit, current_time))

        LastModified.touch(self._fullname, "Visit")
开发者ID:numo16,项目名称:reddit,代码行数:14,代码来源:account.py

示例2: update_last_visit

# 需要导入模块: from r2.models.last_modified import LastModified [as 别名]
# 或者: from r2.models.last_modified.LastModified import get [as 别名]
    def update_last_visit(self, current_time):
        from admintools import apply_updates

        timer = g.stats.get_timer("account.update_last_visit")
        timer.start()

        apply_updates(self, timer)

        prev_visit = LastModified.get(self._fullname, "Visit")
        timer.intermediate("get_last_modified")

        if prev_visit and current_time - prev_visit < timedelta(days=1):
            timer.intermediate("set_last_modified.noop")
            timer.stop()
            return

        LastModified.touch(self._fullname, "Visit")
        timer.intermediate("set_last_modified.done")
        timer.stop()
开发者ID:XPRIYA,项目名称:HMWK2PartB,代码行数:21,代码来源:account.py

示例3: fast_query

# 需要导入模块: from r2.models.last_modified import LastModified [as 别名]
# 或者: from r2.models.last_modified.LastModified import get [as 别名]
    def fast_query(cls, thing1, thing2s):
        """Find relationships between thing1 and various thing2s."""
        thing2s, thing2s_is_single = tup(thing2s, ret_is_single=True)

        if not thing1:
            return {}

        # don't bother looking up relationships for items that were created
        # since the last time the thing1 created a relationship of this type
        if cls._last_modified_name:
            from r2.models.last_modified import LastModified
            timestamp = LastModified.get(thing1._fullname,
                                         cls._last_modified_name)
            if timestamp:
                thing2s = [thing2 for thing2 in thing2s
                           if thing2._date <= timestamp]
            else:
                thing2s = []

        if not thing2s:
            return {}

        # fetch the row from cassandra. if it doesn't exist, thing1 has no
        # relation of this type to any thing2!
        try:
            columns = [thing2._id36 for thing2 in thing2s]
            results = cls._cf.get(thing1._id36, columns)
        except NotFoundException:
            results = {}

        # return the data in the expected format
        if not thing2s_is_single:
            # {(thing1, thing2) : value}
            thing2s_by_id = {thing2._id36 : thing2 for thing2 in thing2s}
            return {(thing1, thing2s_by_id[k]) : v
                    for k, v in results.iteritems()}
        else:
            if results:
                assert len(results) == 1
                return results.values()[0]
            else:
                raise NotFound("<%s %r>" % (cls.__name__, (thing1._id36,
                                                           thing2._id36)))
开发者ID:AHAMED750,项目名称:reddit,代码行数:45,代码来源:tdb_cassandra.py


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