本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.fields[field_name2]方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.fields[field_name2]方法的具体用法?Python Tiddler.fields[field_name2]怎么用?Python Tiddler.fields[field_name2]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.fields[field_name2]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_a_bunch
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields[field_name2] [as 别名]
def test_make_a_bunch():
for x in xrange(RANGE):
bag_name = u'bag%s' % x
recipe_name = u'recipe%s' % x
tiddler_name = u'tiddler%s' % x
recipe_list = [(bag_name, '')]
tiddler_text = u'hey ho %s' % x
field_name = u'field%s' % x
field_name2 = u'fieldone%s' % x
tag_name = u'tag%s' % x
user_name = u'user%s' % x
user_pass = u'pass%s' % x
user_note = u'note%s' % x
user_roles = [u'rolehold', u'role%s' % x]
bag = Bag(bag_name)
bag.policy.owner = u'owner%s' % x
bag.policy.read = [u'hi%s' % x, u'andextra']
bag.policy.manage = [u'R:hi%s' % x, u'andmanage']
store.put(bag)
recipe = Recipe(recipe_name)
recipe.policy.owner = u'owner%s' % x
recipe.policy.read = [u'hi%s' % x, u'andextra']
recipe.policy.manage = [u'R:hi%s' % x, u'andmanage']
recipe.set_recipe(recipe_list)
store.put(recipe)
tiddler = Tiddler(tiddler_name, bag_name)
tiddler.text = tiddler_text
tiddler.fields[field_name] = field_name
tiddler.fields[field_name2] = field_name2
tiddler.fields['server.host'] = 'gunky'
tiddler.tags = [tag_name]
store.put(tiddler)
store.put(tiddler)
user = User(user_name)
user.set_password(user_pass)
user.note = user_note
for role in user_roles:
user.add_role(role)
store.put(user)
bags = [bag.name for bag in store.list_bags()]
recipes = [recipe.name for recipe in store.list_recipes()]
users = [user.usersign for user in store.list_users()]
assert len(bags) == RANGE
assert len(recipes) == RANGE
assert len(users) == RANGE
for x in xrange(RANGE):
bname = 'bag%s' % x
rname = 'recipe%s' % x
uname = 'user%s' % x
assert bname in bags
assert rname in recipes
assert uname in users
tiddler = store.get(Tiddler(u'tiddler0', u'bag0'))
assert tiddler.fields['field0'] == 'field0'
assert tiddler.fields['fieldone0'] == 'fieldone0'
bag = Bag(u'bag0')
bag = store.get(bag)
tiddlers = []
for tiddler in store.list_bag_tiddlers(bag):
tiddlers.append(store.get(tiddler))
assert len(tiddlers) == 1
assert tiddlers[0].title == 'tiddler0'
assert tiddlers[0].fields['field0'] == 'field0'
assert tiddlers[0].fields['fieldone0'] == 'fieldone0'
assert tiddlers[0].tags == ['tag0']
assert sorted(bag.policy.read) == ['andextra', 'hi0']
assert sorted(bag.policy.manage) == ['R:hi0', u'andmanage']
assert bag.policy.owner == 'owner0'
user = User(u'user1')
user = store.get(user)
assert user.usersign == 'user1'
assert user.check_password('pass1')
assert user.note == 'note1'
assert 'role1' in user.list_roles()
assert 'rolehold' in user.list_roles()
recipe = Recipe(u'recipe2')
recipe = store.get(recipe)
assert recipe.name == 'recipe2'
bags = [bag_name for bag_name, filter in recipe.get_recipe()]
assert len(bags) == 1
assert 'bag2' in bags
assert sorted(recipe.policy.read) == ['andextra', 'hi2']
assert sorted(recipe.policy.manage) == ['R:hi2', u'andmanage']
assert recipe.policy.owner == 'owner2'
recipe.policy.manage = [u'andmanage']
store.put(recipe)
recipe = Recipe (u'recipe2')
recipe = store.get(recipe)
assert recipe.policy.manage == [u'andmanage']
# delete the above things
store.delete(bag)
#.........这里部分代码省略.........