當前位置: 首頁>>代碼示例>>Python>>正文


Python cachecontrol.CacheControl類代碼示例

本文整理匯總了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;未經允許,請勿轉載。