• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cachecontrol.CacheControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webob.cachecontrol.CacheControl的典型用法代码示例。如果您正苦于以下问题:Python CacheControl类的具体用法?Python CacheControl怎么用?Python CacheControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _cache_control__get

 def _cache_control__get(self):
     """
     Get/set/modify the Cache-Control header (section `14.9
     <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
     """
     value = self.headers.get('cache-control', '')
     if self._cache_control_obj is None:
         self._cache_control_obj = CacheControl.parse(value, updates_to=self._update_cache_control, type='response')
         self._cache_control_obj.header_value = value
     if self._cache_control_obj.header_value != value:
         new_obj = CacheControl.parse(value, type='response')
         self._cache_control_obj.properties.clear()
         self._cache_control_obj.properties.update(new_obj.properties)
         self._cache_control_obj.header_value = value
     return self._cache_control_obj
开发者ID:openplans,项目名称:geowebdns-lib,代码行数:15,代码来源:response.py


示例2: test_parse_valueerror_int

 def test_parse_valueerror_int(self):
     from webob.cachecontrol import CacheControl
     def foo(arg):
         return {'a': 1}
     cc = CacheControl.parse("public, max-age=abc")
     assert type(cc) == CacheControl
     assert cc.max_age == 'abc'
开发者ID:SmartTeleMax,项目名称:webob,代码行数:7,代码来源:test_cachecontrol.py


示例3: test_parse_updates_to

 def test_parse_updates_to(self):
     from webob.cachecontrol import CacheControl
     def foo(arg):
         return {'a': 1}
     cc = CacheControl.parse("public, max-age=315360000", updates_to=foo)
     assert type(cc) == CacheControl
     assert cc.max_age == 315360000
开发者ID:SmartTeleMax,项目名称:webob,代码行数:7,代码来源:test_cachecontrol.py


示例4: _cache_control__get

 def _cache_control__get(self):
     """
     Get/set/modify the Cache-Control header (section `14.9
     <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
     """
     env = self.environ
     value = env.get('HTTP_CACHE_CONTROL', '')
     cache_header, cache_obj = env.get('webob._cache_control', (None, None))
     if cache_obj is not None and cache_header == value:
         return cache_obj
     cache_obj = CacheControl.parse(value, type='request')
     env['webob._cache_control'] = (value, cache_obj)
     return cache_obj
开发者ID:daevaorn,项目名称:scraperasaservice.appspot.com,代码行数:13,代码来源:request.py


示例5: _cache_control__get

 def _cache_control__get(self):
     """
     Get/set/modify the Cache-Control header (`HTTP spec section 14.9
     <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
     """
     env = self.environ
     value = env.get("HTTP_CACHE_CONTROL", "")
     cache_header, cache_obj = env.get("webob._cache_control", (None, None))
     if cache_obj is not None and cache_header == value:
         return cache_obj
     cache_obj = CacheControl.parse(value, updates_to=self._update_cache_control, type="request")
     env["webob._cache_control"] = (value, cache_obj)
     return cache_obj
开发者ID:Poorvak,项目名称:twitter_clone,代码行数:13,代码来源:request.py


示例6: _cache_control__set

 def _cache_control__set(self, value):
     # This actually becomes a copy
     if not value:
         value = ""
     if isinstance(value, dict):
         value = CacheControl(value, 'response')
     if isinstance(value, text_type):
         value = str(value)
     if isinstance(value, str):
         if self._cache_control_obj is None:
             self.headers['Cache-Control'] = value
             return
         value = CacheControl.parse(value, 'response')
     cache = self.cache_control
     cache.properties.clear()
     cache.properties.update(value.properties)
开发者ID:nkunal,项目名称:webob,代码行数:16,代码来源:response.py


示例7: test_cache_control_object_max_age_None

def test_cache_control_object_max_age_None():
    from webob.cachecontrol import CacheControl
    cc = CacheControl({}, 'a')
    cc.properties['max-age'] = None
    eq_(cc.max_age, -1)
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:5,代码来源:test_cachecontrol.py


示例8: test_parse_valueerror_int

 def test_parse_valueerror_int(self):
     from webob.cachecontrol import CacheControl
     def foo(arg): return { 'a' : 1 }
     cc = CacheControl.parse("public, max-age=abc")
     self.assertEquals(type(cc), CacheControl)
     self.assertEquals(cc.max_age, 'abc')
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:6,代码来源:test_cachecontrol.py


示例9: test_parse_updates_to

 def test_parse_updates_to(self):
     from webob.cachecontrol import CacheControl
     def foo(arg): return { 'a' : 1 }
     cc = CacheControl.parse("public, max-age=315360000", updates_to=foo)
     self.assertEquals(type(cc), CacheControl)
     self.assertEquals(cc.max_age, 315360000)
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:6,代码来源:test_cachecontrol.py


示例10: test_parse

 def test_parse(self):
     from webob.cachecontrol import CacheControl
     cc = CacheControl.parse("public, max-age=315360000")
     self.assertEquals(type(cc), CacheControl)
     self.assertEquals(cc.max_age, 315360000)
     self.assertEquals(cc.public, True)
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:6,代码来源:test_cachecontrol.py


示例11: test_copy_cc

def test_copy_cc():
    from webob.cachecontrol import CacheControl
    cc = CacheControl({'header':'%', "msg":'arewerichyet?'}, 'request')
    cc2 = cc.copy()
    assert cc.properties is not cc2.properties
    assert cc.type is cc2.type
开发者ID:AgentJay,项目名称:webapp-improved,代码行数:6,代码来源:test_cachecontrol.py


示例12: test_parse

 def test_parse(self):
     from webob.cachecontrol import CacheControl
     cc = CacheControl.parse("public, max-age=315360000")
     assert type(cc) == CacheControl
     assert cc.max_age == 315360000
     assert cc.public is True
开发者ID:SmartTeleMax,项目名称:webob,代码行数:6,代码来源:test_cachecontrol.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compat.bytes_函数代码示例发布时间:2022-05-26
下一篇:
Python byterange.Range类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap