本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.fields方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.fields方法的具体用法?Python Tiddler.fields怎么用?Python Tiddler.fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_field_composed_filter
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_field_composed_filter():
"""
Add a field to a tiddler and then make sure we can filter for it.
"""
tiddler1 = Tiddler('one')
tiddler1.fields = {'status': 'hot'}
tiddler2 = Tiddler('two')
tiddler2.fields = {'status': 'cold'}
tiddler3 = Tiddler('three')
found_tiddlers = filter('select=status:hot', [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['one']
found_tiddlers = filter('select=status:!hot', [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['two', 'three']
found_tiddlers = filter('select=status:cold', [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['two']
found_tiddlers = filter('select=barnabas:monkey', [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == []
found_tiddlers = filter('select=barnabas:!monkey', [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['one', 'two', 'three']
示例2: test_field_composed_filter
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_field_composed_filter():
"""
Add a field to a tiddler and then make sure we can filter for it.
"""
tiddler1 = Tiddler('one')
tiddler1.fields = {'status': 'hot'}
tiddler2 = Tiddler('two')
tiddler2.fields = {'status': 'cold'}
tiddler3 = Tiddler('three')
filter_string = '[status[hot]]'
filters = filter.compose_from_string(filter_string)
found_tiddlers = filter.by_composition(filters, [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['one']
filter_string = '[!status[hot]]'
filters = filter.compose_from_string(filter_string)
found_tiddlers = filter.by_composition(filters, [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['two', 'three']
filter_string = '[status[cold]]'
filters = filter.compose_from_string(filter_string)
found_tiddlers = filter.by_composition(filters, [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['two']
filter_string = '[barnabas[monkey]]'
filters = filter.compose_from_string(filter_string)
found_tiddlers = filter.by_composition(filters, [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == []
filter_string = '[!barnabas[monkey]]'
filters = filter.compose_from_string(filter_string)
found_tiddlers = filter.by_composition(filters, [tiddler1, tiddler2, tiddler3])
assert [tiddler.title for tiddler in found_tiddlers] == ['one', 'two', 'three']
示例3: handler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [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)
示例4: setup_testdata
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def setup_testdata():
testdata = [
{"title":u"Whiskers","tags":["I wRiTe lIke A fIvE yEaR oLd","Kitty","pet","lolcat"],"fields":{"read":"no","badfield":"z"}},
{"title":u"Fred","tags":["dog","pet"],"fields":{"badfield":"xt"}},
{"title":u"Chris","tags":["cat","animal","bogof"],"fields":{"badfield":"ks"}},
{"title":u"Martin","tags":["fish","lion"],"fields":{"badfield":"zs"}},
{"title":u"Jerm","tags":["monkey"],"fields":{"badfield":"z"}},
{"title":u"Paul","tags":["dinosaurs rule","tiger"],"fields":{"badfield":"z"}},
{"title":u"Ben","tags":["cAt","i love my cat"],"fields":{"badfield":"z"}},
{"title":u"Andrew","tags":["Pet","Animal","kitty","ToysRUs"],"fields":{"badfield":"z","foo":"yes"}}
]
tiddlers = []
for tid in testdata:
tiddler = Tiddler(tid["title"],"tmp")
tiddler.fields = tid["fields"]
tiddler.tags = tid["tags"]
tiddlers.append(tiddler)
bag = Bag("tmp")
try:
store.delete(bag)#delete any existing one
except NoBagError:
pass
store.put(bag)
for tiddler in tiddlers:
store.put(tiddler)
示例5: test_cascade
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [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')
示例6: test_title_fields
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_title_fields():
store.put(Bag('abag'))
tiddler = Tiddler('one', 'abag')
tiddler.text = 'hi'
tiddler.fields = {'title': 'two'}
assert tiddler.title == 'one'
assert tiddler.fields['title'] == 'two'
pytest.raises(TiddlerFormatError, 'store.put(tiddler)')
示例7: test_unicode_field_keys
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_unicode_field_keys():
tiddler = Tiddler('two', 'abag')
tiddler.text = 'hi'
tiddler.fields = {u'h\u8976': 'two'}
assert tiddler.fields[u'h\u8976'] == 'two'
store.put(tiddler)
tiddler = store.get(Tiddler('two', 'abag'))
assert tiddler.fields[u'h\u8976'] == 'two'
示例8: test_tiddler_fields_are_stored
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_fields_are_stored():
bag = Bag('bag0')
store.put(bag)
tiddler = Tiddler('feebles', bag='bag0')
tiddler.fields = {'field1': 'value1', 'field2': 'value2'}
store.put(tiddler)
tiddler_second = Tiddler('feebles', bag='bag0')
tiddler_second = store.get(tiddler_second)
assert tiddler_second.fields['field1'] == 'value1'
assert tiddler_second.fields['field2'] == 'value2'
示例9: test_tiddler_fields_are_stored
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_fields_are_stored():
bag = Bag('bag0')
print 'bo ', bag.policy.owner
store.put(bag)
tiddler = Tiddler('feebles', bag='bag0')
tiddler.fields = {u'field1': u'value1', u'field2': u'value2'}
store.put(tiddler)
tiddler_second = Tiddler('feebles', bag='bag0')
tiddler_second = store.get(tiddler_second)
assert tiddler_second.fields['field1'] == 'value1'
assert tiddler_second.fields['field2'] == 'value2'
示例10: test_tiddler_fields_ignore_server
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_fields_ignore_server():
bag = Bag('bag0')
store.put(bag)
tiddler = Tiddler('serverimpostor', bag='bag0')
tiddler.fields = {'field1': 'value1', 'server.host': 'value1', 'server.type': 'value2'}
store.put(tiddler)
tiddler_second = Tiddler('serverimpostor', bag='bag0')
tiddler_second = store.get(tiddler_second)
assert tiddler_second.fields['field1'] == 'value1'
assert 'server.host' not in tiddler_second.fields.keys()
assert 'server.type' not in tiddler_second.fields.keys()
示例11: test_tiddler_fields_ignore_server
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_fields_ignore_server():
bag = Bag('bag0')
store.put(bag)
tiddler = Tiddler('server\nimpostor', bag='bag0')
tiddler.tags = [u'foo\nbar']
tiddler.fields = {u'field1': u'value1\nafterlinefeed', u'server.host': u'value1', u'server.type': u'value2'}
store.put(tiddler)
tiddler_second = Tiddler('server\nimpostor', bag='bag0')
tiddler_second = store.get(tiddler_second)
assert tiddler_second.fields['field1'] == 'value1\nafterlinefeed'
assert 'server.host' not in tiddler_second.fields.keys()
assert 'server.type' not in tiddler_second.fields.keys()
示例12: test_tiddler_field_join
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_field_join():
tiddler = Tiddler("fieldtest", "fnd_public")
tiddler.text = "hi again"
tiddler.fields = {u"barney": u"evil", u"soup": u"good"}
store.put(tiddler)
tiddlers = list(store.search(u"barney:evil"))
assert len(tiddlers) == 1
assert tiddlers[0].title == "fieldtest"
tiddlers = list(store.search(u"barney:evil AND soup:good"))
assert len(tiddlers) == 1
assert tiddlers[0].title == "fieldtest"
示例13: _create_tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def _create_tiddler(commit):
tiddler = Tiddler(commit["id"])
tiddler.bag = bag_name
#tiddler.created = commit["timestamp"] # XXX: convert timestamp
#tiddler.modified = tiddler.created # XXX: use time of notification?
tiddler.modifier = commit["author"]["name"]
tiddler.type = content_type
tiddler.fields = {
"uri": commit["url"],
"files_added": _get_file_changes(commit, "added"),
"files_removed": _get_file_changes(commit, "removed"),
"files_modified": _get_file_changes(commit, "modified")
}
tiddler.text = commit["message"]
return tiddler
示例14: test_tiddler_field_join
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_tiddler_field_join():
tiddler = Tiddler(u'fieldtest', u'fnd_public')
tiddler.text = 'hi again'
tiddler.fields = {
u'barney': u'evil',
u'soup': u'good',
}
store.put(tiddler)
tiddlers = list(store.search(u'barney:evil'))
assert len(tiddlers) == 1
assert tiddlers[0].title == 'fieldtest'
tiddlers = list(store.search(u'barney:evil AND soup:good'))
assert len(tiddlers) == 1
assert tiddlers[0].title == 'fieldtest'
示例15: test_geo_near_tiddlers
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields [as 别名]
def test_geo_near_tiddlers():
# forced single tidder
tiddler = Tiddler('North Sea', bag='gitscob')
tiddler.fields = {u'geo.lat': u'55.0', u'geo.long': u'1.9'}
found = list(geofilters.geo_near_tiddlers(55.0, 1.9, 1.0, [tiddler]))
assert len(found) == 1
assert found[0].fields['_geo.proximity'] == "0.00"
# giant's causway
found = list(geofilters.geo_near_tiddlers(55.23636, -6.50888, 1.0, tiddlers))
assert len(found) == 1
# Scotland
found = list(geofilters.geo_near_tiddlers(55.860, -3.733, 25, tiddlers, "miles"))
assert len(found) == 2
# Cornwall
found = list(geofilters.geo_near_tiddlers(49.916, -6.41, 100, tiddlers, "miles"))
assert len(found) == 3