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


Python Tiddler.text方法代码示例

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


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

示例1: test_interleaved_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_interleaved_tiddler_revisions():
    bag_name = u"bag8"
    for i in xrange(20):
        tiddler1 = Tiddler(u"oh yes", bag_name)
        tiddler2 = Tiddler(u"oh no", bag_name)
        tiddler1.text = u"%s times we yes" % i
        tiddler2.text = u"%s times we no" % i
        tiddler1.fields[u"%s" % i] = u"%s" % i
        tiddler2.fields[u"%s" % i] = u"%s" % i
        store.put(tiddler1)
        store.put(tiddler2)

    revisions = store.list_tiddler_revisions(Tiddler("oh yes", bag_name))
    assert len(revisions) == 20
    first_revision = revisions[-1]
    tiddler = Tiddler("oh yes", bag_name)
    tiddler.revision = first_revision + 26
    tiddler = store.get(tiddler)
    assert tiddler.title == "oh yes"
    assert tiddler.text == "13 times we yes"
    assert tiddler.fields["13"] == "13"
    assert "12" not in tiddler.fields

    tiddler.revision = 90
    py.test.raises(NoTiddlerError, "store.get(tiddler)")

    py.test.raises(NoTiddlerError, 'store.list_tiddler_revisions(Tiddler("sleepy", "cow"))')
开发者ID:pads,项目名称:tiddlywebplugins.mongodb,代码行数:29,代码来源:test_db.py

示例2: test_get_revision

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_get_revision():
    """
    Test we are able to retrieve a particular revision.
    """
    bagone = Bag('bagone')

    store.put(bagone)
    tiddler = Tiddler('RevisionTiddler')
    tiddler.text = 'how now 1'
    tiddler.bag = u'bagone'
    store.put(tiddler)
    tiddler.text = 'how now 2'
    store.put(tiddler)
    tiddler.text = 'how now 3'
    store.put(tiddler)

    tiddler = Tiddler('RevisionTiddler', 'bagone')
    tiddler = store.get(tiddler)

    assert tiddler.text == 'how now 3'
    assert tiddler.revision == 3

    tiddler = Tiddler('RevisionTiddler', 'bagone')
    tiddler.revision = 2
    tiddler = store.get(tiddler)

    assert tiddler.text == 'how now 2'
    assert tiddler.revision == 2

    revisions = store.list_tiddler_revisions(tiddler)
    assert len(revisions) == 3
    assert revisions[0] == 3
开发者ID:24king,项目名称:tiddlyweb,代码行数:34,代码来源:test_store_tiddler.py

示例3: handler

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def handler(environ, start_response):
    input = environ['tiddlyweb.query']
    store = environ['tiddlyweb.store']

    # deal with python cgi packaging
    for field in input:
        if field in SKIP_FIELDS:
            continue
        input[field] = input[field][0]

    # need this to come in on the form input
    tiddler_title = input['tiddler_title']
    del input['tiddler_title']

    tiddler = Tiddler(tiddler_title, TARGET_BAG) # XXX is this the bag you want?
    try:
        tiddler.text = input['text']
        del input['text']
    except KeyError:
        tiddler.text = ''
    tiddler.fields = input

    store.put(tiddler)

    url = '/' # XXX replace with real url
    raise HTTP302(url)
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:28,代码来源:formreader.py

示例4: test_commit

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_commit():
    tiddler = Tiddler('Bar', BAG.name)
    tiddler.type = 'application/binary'
    tiddler.text = 'lorem ipsum'
    STORE.put(tiddler)

    bag_dir = os.path.join(STORE_ROOT, 'bags', 'alpha')
    tiddler_file = os.path.join(bag_dir, 'tiddlers', 'Bar')
    binary_file = os.path.join(bag_dir, 'tiddlers', '_binaries', 'Bar')

    trevs = run('git', 'log', '--format=%h', '--', tiddler_file, cwd=STORE_ROOT)
    brevs = run('git', 'log', '--format=%h', '--', binary_file, cwd=STORE_ROOT)
    assert len(trevs.splitlines()) == 1
    assert len(brevs.splitlines()) == 1
    assert trevs == brevs

    tiddler.text = 'lorem ipsum\ndolor sit amet'
    STORE.put(tiddler)

    trevs = run('git', 'log', '--format=%h', '--', tiddler_file, cwd=STORE_ROOT)
    brevs = run('git', 'log', '--format=%h', '--', binary_file, cwd=STORE_ROOT)
    assert len(trevs.splitlines()) == 2
    assert len(brevs.splitlines()) == 2
    assert trevs == brevs

    STORE.delete(tiddler)

    trevs = run('git', 'log', '--format=%h', '--', tiddler_file, cwd=STORE_ROOT)
    brevs = run('git', 'log', '--format=%h', '--', binary_file, cwd=STORE_ROOT)
    assert len(trevs.splitlines()) == 3
    assert len(brevs.splitlines()) == 3
    assert trevs == brevs
开发者ID:FND,项目名称:tiddlywebplugins.gitstore,代码行数:34,代码来源:test_binary_tiddler.py

示例5: test_interleaved_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_interleaved_tiddler_revisions():
    bag_name = u'bag8'
    for i in xrange(20):
        tiddler1 = Tiddler(u'oh yes', bag_name)
        tiddler2 = Tiddler(u'oh no', bag_name)
        tiddler1.text = u'%s times we yes' % i
        tiddler2.text = u'%s times we no' % i
        tiddler1.fields[u'%s' % i] = u'%s' % i
        tiddler2.fields[u'%s' % i] = u'%s' % i
        store.put(tiddler1)
        store.put(tiddler2)

    revisions = store.list_tiddler_revisions(Tiddler('oh yes', bag_name))
    assert len(revisions) == 20
    first_revision = revisions[-1]
    tiddler = Tiddler('oh yes', bag_name)
    tiddler.revision = first_revision + 26 
    tiddler = store.get(tiddler)
    assert tiddler.title == 'oh yes'
    assert tiddler.text == '13 times we yes'
    assert tiddler.fields['13'] == '13'
    assert '12' not in tiddler.fields

    tiddler.revision = 9999999 # big number to avoid auto increment issues
    py.test.raises(NoTiddlerError, 'store.get(tiddler)')

    py.test.raises(NoTiddlerError,
            'store.list_tiddler_revisions(Tiddler(u"sleepy", u"cow"))')
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.mysql,代码行数:30,代码来源:test_gamut.py

示例6: test_search_follow_syntax

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_search_follow_syntax():
    QUERY = u"ftitle:GettingStarted (bag:cdent_public OR bag:fnd_public)"

    store.put(Bag("fnd_public"))
    store.put(Bag("cdent_public"))
    tiddler = Tiddler("GettingStarted", "fnd_public")
    tiddler.text = u"fnd starts"
    tiddler.fields[u"house"] = u"treehouse"
    tiddler.fields[u"car"] = u"porsche"
    store.put(tiddler)
    tiddler = Tiddler("GettingStarted", "cdent_public")
    tiddler.text = u"cdent starts"
    tiddler.fields[u"left-hand"] = u"well dirty"
    store.put(tiddler)
    tiddler = Tiddler("other", "cdent_public")
    tiddler.text = u"cdent starts"
    store.put(tiddler)

    tiddlers = list(store.search(u"starts"))
    assert len(tiddlers) == 3

    tiddlers = list(store.search(QUERY))
    assert len(tiddlers) == 2

    tiddlers = list(store.search(u"cdent starts"))
    assert len(tiddlers) == 2

    tiddlers = list(store.search(u"fnd starts"))
    assert len(tiddlers) == 1

    tiddler = list(store.search(u'left-hand:"well dirty"'))
    assert len(tiddlers) == 1
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.sqlalchemy,代码行数:34,代码来源:test_search.py

示例7: test_complex_hash_generation

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_complex_hash_generation():
    config['hashmaker.attributes'] = ['text', 'karma']

    tiddler1 = Tiddler('hi')
    tiddler1.text = 'hello'
    tiddler1.fields['karma'] = 'bad'
    hash_tiddler_hook(store.storage, tiddler1)

    tiddler2 = Tiddler('bye')
    tiddler2.text = 'hello'
    tiddler2.fields['karma'] = 'bad'
    hash_tiddler_hook(store.storage, tiddler2)

    assert tiddler1.fields['_hash'] == tiddler2.fields['_hash']

    tiddler2.fields['karma'] = 'good'
    del tiddler2.fields['_hash']
    hash_tiddler_hook(store.storage, tiddler2)

    assert tiddler1.fields['_hash'] != tiddler2.fields['_hash']

    config['hashmaker.attributes'] = ['text']
    del tiddler1.fields['_hash']
    del tiddler2.fields['_hash']
    hash_tiddler_hook(store.storage, tiddler1)
    hash_tiddler_hook(store.storage, tiddler2)
    assert tiddler1.fields['_hash'] == tiddler2.fields['_hash']
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.hashmaker,代码行数:29,代码来源:test_simple.py

示例8: test_spaced_target

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_spaced_target():
    tiddler = Tiddler('Bar')
    environ = {
        'tiddlyweb.config': {
            'markdown.wiki_link_base': '',
            'markdown.interlinker': tank_uri,
            'server_host': {
                'scheme': 'http',
                'host': 'tiddlyspace.com',
                'port': '80'
            }
        }
    }
    tiddler.text = 'I see [[cow fire]]@[[monkey business]] oh hello'
    output = render(tiddler, environ)
    assert '>cow fire<' in output
    assert 'href="http://tiddlyspace.com/tanks/monkey%20business/cow%20fire"' in output
    assert 'fire</a> oh hello' in output

    tiddler.text = 'I see [[fire]]@[[monkey business]]'
    output = render(tiddler, environ)
    assert '>fire<' in output
    assert 'href="http://tiddlyspace.com/tanks/monkey%20business/fire"' in output

    tiddler.text = 'I see @[[monkey business]] inside you'
    output = render(tiddler, environ)
    assert 'href="http://tiddlyspace.com/tanks/monkey%20business"' in output
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.markdown,代码行数:29,代码来源:test_spacelinks.py

示例9: test_web_front

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_web_front():
    bag = Bag('bagone')
    store.put(bag)
    tiddler = Tiddler('tiddlerone', 'bagone')
    tiddler.text = "I am [email protected], http://burningchrome.com/"
    store.put(tiddler)

    http = httplib2.Http()
    response, content = http.request('http://0.0.0.0:8080/bags/bagone/tiddlers/tiddlerone/frontlinks.html')
    assert response['status'] == '200', content
    assert '<a href="/recipes/cdent_public/tiddlers/NotYou">NotYou</a>' in content, content

    bag = Bag('cdent_public')
    store.put(bag)
    tiddler = Tiddler('NotYou', 'cdent_public')
    tiddler.text = 'as BigPoo is'
    store.put(tiddler)

    response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/frontlinks')
    assert '<a href="/bags/cdent_public/tiddlers/BigPoo">BigPoo</a>' in content, content

    response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/backlinks')

    assert '<a href="/bags/barney/tiddlers/hello">hello</a>' in content
    assert '<a href="/bags/bagone/tiddlers/tiddlerone">tiddlerone</a>' in content

    # Use web delete, not store delete as web delete instantiates the tiddler
    #store.delete(Tiddler('hello', 'barney'))
    response, content = http.request('http://0.0.0.0:8080/bags/barney/tiddlers/hello', method='DELETE')
    assert response['status'] == '204'

    response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/backlinks')
 
    assert '<a href="/bags/barney/tiddlers/hello">hello</a>' not in content
开发者ID:FND,项目名称:tiddlywebplugins.links,代码行数:36,代码来源:test_tiddler.py

示例10: test_recipe_variables

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_recipe_variables():
    """
    access a recipe with variables in it
    """
    store = setup_store()
    url(['/foo/{name:segment}', '/recipes/custom/tiddlers'])
    urls_init(config)
    setup_web()
    http = httplib2.Http()

    tiddler = Tiddler('bar baz', 'foo')
    tiddler.text = 'foo bar'
    store.put(tiddler)

    tiddler = Tiddler('default', 'foo')
    tiddler.text = 'foo bar'
    store.put(tiddler)

    recipe = Recipe('custom')
    recipe.set_recipe([('foo', 'select=title:{{ name:default }}')])
    store.put(recipe)

    response, content = http.request('http://test_domain:8001/foo/bar%20baz')

    assert response.status == 200

    direct_url = http.request('http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content != direct_url #accessing directly, the default tiddler should be used instead

    #now check that the correct bag was actually loaded)
    recipe.set_recipe([('foo', 'select=title:bar%20baz')])
    store.put(recipe)
    direct_url = http.request('http://test_domain:8001/recipes/custom/tiddlers')[1]
    assert content == direct_url
开发者ID:bengillies,项目名称:tiddlywebplugins.urls,代码行数:36,代码来源:test_unicode.py

示例11: test_space_server_settings_twrelease

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_space_server_settings_twrelease():
    http = httplib2.Http()
    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200'
    assert '/bags/common/tiddlers/alpha_jquery.js' not in content

    tiddler = Tiddler('ServerSettings', 'foo_public')
    tiddler.text = 'external: True\ntwrelease:alpha'
    store.put(tiddler)

    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200', content
    assert '/bags/common/tiddlers/alpha_jquery.js' in content

    # bad content
    tiddler = Tiddler('ServerSettings', 'foo_public')
    tiddler.text = 'external: True\ntwrelease=alpha'
    store.put(tiddler)

    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200'
    assert '/bags/common/tiddlers/alpha_jquery.js' not in content

    # ignored blank line
    tiddler = Tiddler('ServerSettings', 'foo_public')
    tiddler.text = 'external: True\n\ntwrelease:alpha'
    store.put(tiddler)

    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200'
    assert '/bags/common/tiddlers/alpha_jquery.js' in content
开发者ID:dahukanna,项目名称:tiddlyspace,代码行数:33,代码来源:test_web_use_instance.py

示例12: test_search_unique

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_search_unique():
    bag = Bag('bag1')
    store.put(bag)
    tiddler1 = Tiddler('tiddler1', 'bag1')
    tiddler1.text = 'catsdogshouses'
    store.put(tiddler1)

    tiddler2 = Tiddler('tiddler2', 'bag1')
    tiddler2.text = 'housesdogscats'
    store.put(tiddler2)

    tiddlers = list(search(config, 'catsdogshouses'))
    assert len(tiddlers) == 1
    assert tiddlers[0]['id'] == 'bag1:tiddler1'

    tiddlers = list(search(config, 'housesdogscats'))
    assert len(tiddlers) == 1
    assert tiddlers[0]['id'] == 'bag1:tiddler2'

    store.delete(tiddler1)

    tiddlers = list(search(config, 'catsdogshouses'))
    assert len(tiddlers) == 0

    tiddlers = list(search(config, 'housesdogscats'))
    assert len(tiddlers) == 1
    assert tiddlers[0]['id'] == 'bag1:tiddler2'

    store.delete(tiddler2)

    tiddlers = list(search(config, 'housesdogscats'))
    assert len(tiddlers) == 0
开发者ID:jdlrobson,项目名称:tiddlyweb-plugins,代码行数:34,代码来源:test_delete.py

示例13: test_search_follow_syntax

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_search_follow_syntax():
    QUERY = u'ftitle:GettingStarted (bag:cdent_public OR bag:fnd_public)'

    store.put(Bag(u'fnd_public'))
    store.put(Bag(u'cdent_public'))
    tiddler = Tiddler(u'GettingStarted', u'fnd_public')
    tiddler.text = u'fnd starts'
    tiddler.fields[u'house'] = u'treehouse'
    tiddler.fields[u'car'] = u'porsche'
    store.put(tiddler)
    tiddler = Tiddler(u'GettingStarted', u'cdent_public')
    tiddler.text = u'cdent starts'
    tiddler.fields[u'left-hand'] = u'well dirty'
    store.put(tiddler)
    tiddler = Tiddler(u'other', u'cdent_public')
    tiddler.text = u'cdent starts'
    store.put(tiddler)

    tiddlers = list(store.search(u'starts'))
    assert len(tiddlers) == 3

    tiddlers = list(store.search(QUERY))
    assert len(tiddlers) == 2

    tiddlers = list(store.search(u'cdent starts'))
    assert len(tiddlers) == 2

    tiddlers = list(store.search(u'fnd starts'))
    assert len(tiddlers) == 1

    tiddler = list(store.search(u'left-hand:"well dirty"'))
    assert len(tiddlers) == 1
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.mysql,代码行数:34,代码来源:test_search.py

示例14: test_multiword_phrase_search

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_multiword_phrase_search():
    tiddler = Tiddler("one", "cdent_public")
    tiddler.text = "monkeys are fun!"
    store.put(tiddler)
    tiddler = Tiddler("one two", "cdent_public")
    tiddler.text = "monkeys are fun!"
    store.put(tiddler)
    tiddler = Tiddler("one two three", "cdent_public")
    tiddler.text = "monkeys are fun!"
    store.put(tiddler)
    tiddler = Tiddler("three two one", "cdent_public")
    tiddler.text = "monkeys are fun!"
    store.put(tiddler)

    response, content = http.request("http://0.0.0.0:8080/search.json?q=ftitle:one")
    assert response["status"] == "200"
    info = simplejson.loads(content)
    assert len(info) == 1, info

    response, content = http.request("http://0.0.0.0:8080/search.json?q=ftitle:one%20two")
    assert response["status"] == "200"
    info = simplejson.loads(content)
    assert len(info) == 0, info

    response, content = http.request("http://0.0.0.0:8080/search.json?q=ftitle:one%20two%20three")
    assert response["status"] == "200"
    info = simplejson.loads(content)
    assert len(info) == 0, info

    response, content = http.request("http://0.0.0.0:8080/search.json?q=ftitle:%22one%20two%20three%22")
    assert response["status"] == "200"
    info = simplejson.loads(content)
    assert len(info) == 1, info
开发者ID:pads,项目名称:tiddlyspace,代码行数:35,代码来源:test_search.py

示例15: test_space_server_settings_index

# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import text [as 别名]
def test_space_server_settings_index():
    http = httplib2.Http()
    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200'
    assert 'TiddlyWiki' in content

    tiddler = Tiddler('ServerSettings', 'foo_public')
    tiddler.text = 'index: MySPA\n'
    store.put(tiddler)

    http = httplib2.Http()
    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '404'

    tiddler = Tiddler('MySPA', 'foo_public')
    tiddler.text = '<html><h1>Hello!</h1></html>'
    tiddler.type = 'text/html'
    store.put(tiddler)

    http = httplib2.Http()
    response, content = http.request('http://foo.0.0.0.0:8080/')
    assert response['status'] == '200'

    assert '<h1>Hello!</h1>' in content
    assert 'TiddlyWiki' not in content
    assert 'TiddlyWeb' not in content
开发者ID:dahukanna,项目名称:tiddlyspace,代码行数:28,代码来源:test_web_use_instance.py


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