本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.tags方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.tags方法的具体用法?Python Tiddler.tags怎么用?Python Tiddler.tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.tags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_boolean
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_boolean():
"""
We expect a default AND but can do OR.
"""
store.put(Bag('mybag'))
tiddlera = Tiddler('a', 'mybag')
tiddlera.tags = ['one', '@two']
store.put(tiddlera)
tiddlerb = Tiddler('b', 'mybag')
tiddlerb.tags = ['@two', 'three']
store.put(tiddlerb)
tiddlerc = Tiddler('c', 'mybag')
tiddlerc.tags = ['three', 'four']
store.put(tiddlerc)
tiddlers = list(search(config, 'tags:one'))
assert len(tiddlers) == 1
tiddlers = list(search(config, 'tags:@two'))
assert len(tiddlers) == 2
tiddlers = list(search(config, 'tags:one tags:@two'))
assert len(tiddlers) == 1
tiddlers = list(search(config, 'tags:one tags:four'))
assert len(tiddlers) == 0
tiddlers = list(search(config, 'tags:one OR tags:four'))
assert len(tiddlers) == 2
示例2: test_or_tags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_or_tags():
tiddler = Tiddler(u'tagone', u'fnd_public')
tiddler.text = 'hi @onething hello'
tiddler.tags = ['one','three', 'five']
store.put(tiddler)
tiddler = Tiddler(u'tagtwo', u'fnd_public')
tiddler.text = 'hi @twothing hello'
tiddler.tags = ['two', 'four', 'six']
store.put(tiddler)
tiddlers = list(store.search(u'@twothing OR tag:one'))
assert len(tiddlers) == 2
示例3: test_or_tags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_or_tags():
tiddler = Tiddler("tagone", "fnd_public")
tiddler.text = "hi @onething hello"
tiddler.tags = ["one", "three", "five"]
store.put(tiddler)
tiddler = Tiddler("tagtwo", "fnd_public")
tiddler.text = "hi @twothing hello"
tiddler.tags = ["two", "four", "six"]
store.put(tiddler)
tiddlers = list(store.search(u"@twothing OR tag:one"))
assert len(tiddlers) == 2
示例4: test_modified
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_modified():
"""
Note the multiple store.put in here are to create
additional revisions to make sure that joins are
sufficiently limited.
"""
tiddler = Tiddler(u'GettingStarted', u'fnd_public')
tiddler.modifier = u'fnd';
store.put(tiddler)
tiddlers = list(store.search(u'modifier:fnd'))
assert len(tiddlers) == 1
tiddler = Tiddler(u'GettingStarted', u'fnd_public')
tiddler.tags = [u'monkey', u'cow', u'food']
tiddler.modifier = u'cdent';
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
tiddlers = list(store.search(u'modifier:fnd'))
assert len(tiddlers) == 0
tiddler = Tiddler(u'GettingFancy', u'fnd_public')
tiddler.tags = [u'cow', u'food']
tiddler.modifier = u'fnd';
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
tiddlers = list(store.search(u'modifier:fnd OR modifier:cdent'))
assert len(tiddlers) == 2
tiddlers = list(store.search(u'modifier:fnd NOT modifier:cdent'))
assert len(tiddlers) == 1
tiddlers = list(store.search(u'modifier:fnd NOT (modifier:cdent OR title:GettingStarted)'))
assert len(tiddlers) == 1
tiddlers = list(store.search(u'modifier:fnd AND modified:20*'))
assert len(tiddlers) == 1
示例5: test_modified
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_modified():
"""
Note the multiple store.put in here are to create
additional revisions to make sure that joins are
sufficiently limited.
"""
tiddler = Tiddler("GettingStarted", "fnd_public")
tiddler.modifier = u"fnd"
store.put(tiddler)
tiddlers = list(store.search(u"modifier:fnd"))
assert len(tiddlers) == 1
tiddler = Tiddler("GettingStarted", "fnd_public")
tiddler.tags = [u"monkey", u"cow", u"food"]
tiddler.modifier = u"cdent"
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
tiddlers = list(store.search(u"modifier:fnd"))
assert len(tiddlers) == 0
tiddler = Tiddler("GettingFancy", "fnd_public")
tiddler.tags = [u"cow", u"food"]
tiddler.modifier = u"fnd"
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
store.put(tiddler)
tiddlers = list(store.search(u"modifier:fnd OR modifier:cdent"))
assert len(tiddlers) == 2
tiddlers = list(store.search(u"modifier:fnd NOT modifier:cdent"))
assert len(tiddlers) == 1
tiddlers = list(store.search(u"modifier:fnd NOT (modifier:cdent OR title:GettingStarted)"))
assert len(tiddlers) == 1
tiddlers = list(store.search(u"modifier:fnd AND modified:20*"))
assert len(tiddlers) == 1
示例6: handle_tiddler_div
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def handle_tiddler_div(bagname, tiddler_div, store):
"""
Create a new Tiddler from a tiddler div, in beautifulsoup
form.
"""
new_tiddler = Tiddler(tiddler_div['title'], bag=bagname)
try:
new_tiddler.text = _html_decode(tiddler_div.find('pre').contents[0])
except IndexError:
# there are no contents in the tiddler
new_tiddler.text = ''
for attr, value in tiddler_div.attrs:
data = tiddler_div.get(attr, None)
if data and attr != 'tags':
if attr in (['modifier', 'created', 'modified']):
new_tiddler.__setattr__(attr, data)
else:
new_tiddler.fields[attr] = data
new_tiddler.tags = _tag_string_to_list(tiddler_div.get('tags', ''))
try:
store.put(new_tiddler)
except OSError, exc:
# This tiddler has a name that we can't yet write to the
# store. For now we just state the error and carry on.
import sys
print >> sys.stderr, 'Unable to write %s: %s' % (new_tiddler.title, exc)
示例7: test_for_tags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_for_tags():
tiddler1 = Tiddler('one', 'bagone')
tiddler2 = Tiddler('two', 'bagtwo')
tiddler1.tags = ['alpha', 'beta']
tiddler2.tags = ['alpha', 'gamma']
store.put(tiddler1)
store.put(tiddler2)
tags = get_indexed_tags(config, None)
assert len(tags) == 3
assert sorted(tags) == ['alpha', 'beta', 'gamma']
tags = get_indexed_tags(config, 'bag:"bagone"')
assert len(tags) == 2
assert sorted(tags) == ['alpha', 'beta']
示例8: test_view
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_view():
"""
test a request for viewing a single tiddler
"""
#setup
setup(store)
tiddler = Tiddler('GettingStarted', 'jon_private')
tiddler.text = 'the cat jumped over the moon'
tiddler.tags = ['hello', 'world']
store.put(tiddler)
#run
email = mailer.handle_email({
'to': '[email protected]',
'from': '[email protected]',
'subject': 'GettingStarted',
'body': ''
})
#verify
assert email == {
'to': '[email protected]',
'from': '[email protected]',
'subject': 'GettingStarted',
'body': 'the cat jumped over the moon'
}
示例9: test_post_existing
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_post_existing():
"""
testing posting an existing tiddler to check that it is overwritten
"""
#setup
setup(store)
tiddler = Tiddler('i exist','jon_private')
tiddler.fields['geo.lat'] = '20'
tiddler.fields['geo.long'] = '2'
tiddler.text = 'data'
tiddler.tags = ['a', 'b']
store.put(tiddler)
#run
mailer.handle_email({
'to': '[email protected]',
'from': '[email protected]',
'subject': 'i exist',
'body': 'wipeout'
})
#verify
tiddler = store.get(Tiddler('i exist', 'jon_private'))
assert tiddler.text == 'wipeout'
assert tiddler.fields.get('geo.lat') == None
示例10: test_revisions_deletions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_revisions_deletions():
tiddler = Tiddler('tone', 'pone')
tiddler.text = u'revision1'
tiddler.tags = [u'1', u'2']
STORE.put(tiddler)
tiddler.text = u'revision2'
tiddler.tags = [u'3', u'4']
STORE.put(tiddler)
revisions = STORE.list_tiddler_revisions(tiddler)
assert len(revisions) == 2
STORE.delete(tiddler)
py.test.raises(NoTiddlerError, 'STORE.list_tiddler_revisions(tiddler)')
示例11: url
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def url(args):
"""Add a URL via tiddlywebplugins.URLs. Redirect is optional. [--redirect] <selector_path> <destination_url>"""
if 2 != len(args) != 3:
print >> sys.stderr, ('you must include both the path you want to use (selector path) and the destination url')
store = get_store(config)
if args[0] == '--redirect':
redirect = args.pop(0).lstrip('-')
else:
redirect = None
selector_path = args[0]
destination_url = args[1]
tiddler = Tiddler(selector_path)
tiddler.bag = config['url_bag']
tiddler.text = destination_url
if redirect:
tiddler.tags = [redirect]
if validate_url(tiddler):
store.put(tiddler)
return True
示例12: test_in_a_recipe
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_in_a_recipe():
from tiddlyweb.config import config
store = get_store(config)
bag = Bag('hi')
store.put(bag)
tiddler = Tiddler('thing1', 'hi')
tiddler.tags = ['research']
store.put(tiddler)
tiddler = Tiddler('thing2', 'hi')
store.put(tiddler)
recipe1 = Recipe('oi')
recipe1.set_recipe([('hi', 'mselect=tag:research')])
recipe1.store = store
recipe2 = Recipe('coi')
recipe2.set_recipe([('hi', 'select=tag:research')])
recipe2.store = store
recipe3 = Recipe('boi')
recipe3.set_recipe([('hi', '')])
recipe3.store = store
environ = {'tiddlyweb.store': store}
tiddlers = list(control.get_tiddlers_from_recipe(recipe1, environ))
assert len(tiddlers) == 1
tiddlers = list(control.get_tiddlers_from_recipe(recipe2, environ))
assert len(tiddlers) == 1
tiddlers = list(control.get_tiddlers_from_recipe(recipe3, environ))
assert len(tiddlers) == 2
示例13: test_cascade
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_cascade():
bag = Bag(u'holder')
store.put(bag)
tiddler = Tiddler(u'one', u'holder')
tiddler.text = u'text'
tiddler.tags = [u'tag']
tiddler.fields = {u'fieldone': u'valueone'}
store.put(tiddler)
def count_em(count, message):
text_count = store.storage.session.query(sText).count()
tag_count = store.storage.session.query(sTag).count()
tiddler_count = store.storage.session.query(sTiddler).count()
revision_count = store.storage.session.query(sRevision).count()
field_count = store.storage.session.query(sField).count()
store.storage.session.commit()
message = ('%s, but got: text: %s, tag: %s, tiddler: %s, '
'revision: %s, field: %s') % (message, text_count, tag_count,
tiddler_count, revision_count, field_count)
assert (text_count == tag_count == tiddler_count
== revision_count == field_count == count), message
count_em(1, '1 row for the tiddler everywhere')
store.delete(tiddler)
count_em(0, '0 rows for the tiddler everywhere')
示例14: test_revision_get
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_revision_get():
bag = Bag('alpha')
STORE.put(bag)
# create a bunch of revisions
tiddler_data = [
{ 'text': 'hello world', 'tags': ['foo'] },
{ 'text': 'lorem ipsum', 'tags': ['foo', 'bar'] },
{ 'text': 'lorem ipsum\ndolor sit amet', 'tags': [] }
]
for tid in tiddler_data:
tiddler = Tiddler('Foo', bag.name)
tiddler.text = tid['text']
tiddler.tags = tid['tags']
STORE.put(tiddler)
tid['revision'] = tiddler.revision
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = None
tiddler = STORE.get(tiddler)
assert tiddler.text == 'lorem ipsum\ndolor sit amet'
assert len(tiddler.tags) == 0
for i, tid in enumerate(tiddler_data):
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = tid['revision']
tiddler = STORE.get(tiddler)
assert tiddler.text == tid['text']
assert len(tiddler.revision) == 10
assert len(tiddler.tags) == len(tid['tags'])
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = 'N/A'
with raises(NoTiddlerError):
STORE.get(tiddler)
示例15: test_simple_magic
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import tags [as 别名]
def test_simple_magic():
bag = Bag('MAGICUSER')
store.put(bag)
extractor = Extractor()
userinfo = {'name': 'cdent', 'roles': ['HELLO']}
more_info = extractor.extract_more_info(environ, userinfo)
assert 'modifier' in more_info
assert 'name' in more_info
assert 'roles' in more_info
assert 'tags' in more_info
assert 'fields' in more_info
assert 'modified' in more_info
assert more_info['tags'] == []
assert more_info['fields'] == {}
assert more_info['roles'] == ['HELLO']
tiddler = Tiddler('cdent', 'MAGICUSER')
tiddler.fields['roles'] = "GOODBYE CHRISTMAS EASTER ADMIN"
tiddler.tags = ['monkey', 'hello', 'barney']
tiddler.fields['spaces'] = "one two three"
store.put(tiddler)
more_info = extractor.extract_more_info(environ, userinfo)
assert sorted(more_info['tags']) == [u'barney', u'hello', u'monkey']
assert len(more_info['roles']) == 5
for role in ['HELLO', 'GOODBYE', 'CHRISTMAS', 'EASTER', 'ADMIN']:
assert role in more_info['roles']
assert more_info['fields']['spaces'] == 'one two three'