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


Python Setting.smarthistory_version方法代码示例

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


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

示例1: clearCache

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import smarthistory_version [as 别名]
 def clearCache():
     Setting.smarthistory_version(int(Setting.smarthistory_version()) + 1)  
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:4,代码来源:smarthistory.py

示例2: SmartHistoryLoadException

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import smarthistory_version [as 别名]
            else:
                raise SmartHistoryLoadException(response.status_code)     
        except Exception, e:
            raise SmartHistoryLoadException("Post attempt failed to SmartHsitory with :"+str(e))  
            return      

        self.response.out.write(data)   

    @staticmethod
    def clearCache():
        Setting.smarthistory_version(int(Setting.smarthistory_version()) + 1)  

    #load the resource from smart history's server and then cache it in the data store
    #if it is an image then cache it in the blob store and store the blobkey in the data store 
    @layer_cache.cache_with_key_fxn(
        lambda self: "smart_history_v%s_%s" % (Setting.smarthistory_version(), self.request.path_qs), 
        layer = layer_cache.Layers.Datastore, 
        expiration = SMARTHISTORY_CACHE_EXPIRATION_TIME, 
        persist_across_app_versions = True, 
        permanent_key_fxn = lambda self: "smart_history_permanent_%s" % (self.request.path_qs))
    def load_resource(self):
        path = self.request.path

        #img is in users browser cache - we don't want to cache a Not-Modified response otherwise people who don't have image in browser cache won't get it
        headers = dict((k, v) for (k, v) in self.request.headers.iteritems() if k not in ["If-Modified-Since", "If-None-Match", "Content-Length","Host"])

        logging.info("getting resource " + str(path) + " from "+SMARTHISTORY_URL);       
        try:
            response = urlfetch.fetch(url = SMARTHISTORY_URL + path, headers = headers, deadline=25)
        except urlfetch.ResponseTooLargeError, e:
            logging.info("got too large a file back, sending redirect headers")
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:33,代码来源:smarthistory.py


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