本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.fields["_cache-max-age"]方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.fields["_cache-max-age"]方法的具体用法?Python Tiddler.fields["_cache-max-age"]怎么用?Python Tiddler.fields["_cache-max-age"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.fields["_cache-max-age"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_tiddler_manual_cache
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields["_cache-max-age"] [as 别名]
def test_get_tiddler_manual_cache():
[os.unlink(".test_cache/%s" % x) for x in os.listdir(".test_cache")]
http = httplib2.Http(".test_cache")
tiddler = Tiddler("cached", "bag28")
tiddler.text = "hi!"
tiddler.fields["_cache-max-age"] = 3000
store.put(tiddler)
response, content = http.request("http://our_test_domain:8001/bags/bag28/tiddlers/cached")
assert not response.fromcache
assert response["status"] == "200"
assert response["cache-control"] == "max-age=3000, no-transform"
assert "text/html; charset=UTF-8" in response["content-type"]
htmletag = response["etag"]
response, content = http.request(
"http://our_test_domain:8001/bags/bag28/tiddlers/cached", headers={"Accept": "text/plain"}
)
assert not response.fromcache
assert response["status"] == "200"
assert response["cache-control"] == "max-age=3000, no-transform"
assert "text/plain; charset=UTF-8" in response["content-type"]
response, content = http.request("http://our_test_domain:8001/bags/bag28/tiddlers/cached")
# this one does not cache because we Vary on Accept
assert not response.fromcache
assert response["status"] == "200"
assert response["etag"] == htmletag
response, content = http.request("http://our_test_domain:8001/bags/bag28/tiddlers/cached")
assert response.fromcache
assert response["status"] == "304"
assert "text/html; charset=UTF-8" in response["content-type"]
assert response["etag"] == htmletag
tiddler = Tiddler("notcached", "bag28")
tiddler.text = "hi!"
tiddler.fields["_cache-max-age"] = "salami"
store.put(tiddler)
response, content = http.request("http://our_test_domain:8001/bags/bag28/tiddlers/notcached")
assert not response.fromcache
assert response["status"] == "200"
assert response["cache-control"] == "no-cache, no-transform"
assert "max-age" not in response["cache-control"]
assert "text/html; charset=UTF-8" in response["content-type"]