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


Python Tiddler.fields['_cache-max-age']方法代码示例

本文整理汇总了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']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']
开发者ID:tup,项目名称:tiddlyweb,代码行数:51,代码来源:test_web_tiddler.py

示例2: test_get_maxage_tiddler

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields['_cache-max-age'] [as 别名]
def test_get_maxage_tiddler():
    bag = Bag(_random_name())
    store.put(bag)

    tiddler = Tiddler(_random_name(), bag.name)
    tiddler.text = _random_name(10)
    tiddler.fields['_cache-max-age'] = '3600'
    store.put(tiddler)

    _get_entity('http://our_test_domain:8001/bags/%s/tiddlers/%s' % (
        bag.name, tiddler.title), test_last_modified=True)
开发者ID:FND,项目名称:tiddlyweb,代码行数:13,代码来源:test_web_304_handling.py


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