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


Python CacheControl.parse方法代码示例

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


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

示例1: _cache_control__get

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:17,代码来源:response.py

示例2: test_parse_valueerror_int

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:9,代码来源:test_cachecontrol.py

示例3: test_parse_updates_to

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:9,代码来源:test_cachecontrol.py

示例4: _cache_control__get

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:15,代码来源:request.py

示例5: _cache_control__get

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:15,代码来源:request.py

示例6: _cache_control__set

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:18,代码来源:response.py

示例7: test_parse_valueerror_int

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:8,代码来源:test_cachecontrol.py

示例8: test_parse_updates_to

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:8,代码来源:test_cachecontrol.py

示例9: test_parse

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:8,代码来源:test_cachecontrol.py

示例10: test_parse

# 需要导入模块: from webob.cachecontrol import CacheControl [as 别名]
# 或者: from webob.cachecontrol.CacheControl import parse [as 别名]
 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,代码行数:8,代码来源:test_cachecontrol.py


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