本文整理汇总了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;未经允许,请勿转载。 |
请发表评论