本文整理汇总了Python中tiddlyweb.store.Store.get方法的典型用法代码示例。如果您正苦于以下问题:Python Store.get方法的具体用法?Python Store.get怎么用?Python Store.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.store.Store
的用法示例。
在下文中一共展示了Store.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_bag_policies
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_create_bag_policies(self):
spawn(instance_dir, config, instance_module)
os.chdir(instance_dir)
store = Store(config['server_store'][0],
config['server_store'][1], environ=self.env)
bag = Bag('system')
system_policy = store.get(bag).policy
bag = Bag('common')
common_policy = store.get(bag).policy
assert system_policy.read == []
assert system_policy.write == ['R:ADMIN']
assert system_policy.create == ['R:ADMIN']
assert system_policy.manage == ['R:ADMIN']
assert system_policy.accept == ['R:ADMIN']
assert system_policy.delete == ['R:ADMIN']
assert common_policy.read == []
assert common_policy.write == []
assert common_policy.create == []
assert common_policy.manage == ['R:ADMIN']
assert common_policy.accept == []
assert common_policy.delete == []
os.chdir('..')
示例2: test_tiddler_limit_field
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_tiddler_limit_field():
store = Store('tiddlywebplugins.mappingsql', {'db_config': 'sqlite:///test.db'}, {'tiddlyweb.config': config})
tiddler = Tiddler('monkey', 'avox')
tiddler = store.get(tiddler)
assert tiddler.fields['field_one'] == 'fat'
assert 'field_three' not in tiddler.fields
assert 'field_two' not in tiddler.fields
store = Store('tiddlywebplugins.mappingsql', {'db_config': 'sqlite:///test.db'}, {
'tiddlyweb.config': config,
'tiddlyweb.usersign': {'name': 'zow'}
})
tiddler = Tiddler('monkey', 'avox')
tiddler = store.get(tiddler)
assert tiddler.fields['field_one'] == 'fat'
assert 'field_three' in tiddler.fields
assert 'field_two' in tiddler.fields
store = Store('tiddlywebplugins.mappingsql', {'db_config': 'sqlite:///test.db'}, {
'tiddlyweb.config': config,
'tiddlyweb.usersign': {'name': u'GUEST'}
})
tiddler = Tiddler('monkey', 'avox')
tiddler = store.get(tiddler)
assert tiddler.fields['field_one'] == 'fat'
assert 'field_three' not in tiddler.fields
assert 'field_two' not in tiddler.fields
示例3: test_tiddler_limit_field
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_tiddler_limit_field():
store = Store("tiddlywebplugins.mappingsql", {"db_config": "sqlite:///test.db"}, {"tiddlyweb.config": config})
tiddler = Tiddler("monkey", "avox")
tiddler = store.get(tiddler)
assert tiddler.fields["field_one"] == "fat"
assert "field_three" not in tiddler.fields
assert "field_two" not in tiddler.fields
store = Store(
"tiddlywebplugins.mappingsql",
{"db_config": "sqlite:///test.db"},
{"tiddlyweb.config": config, "tiddlyweb.usersign": {"name": "zow"}},
)
tiddler = Tiddler("monkey", "avox")
tiddler = store.get(tiddler)
assert tiddler.fields["field_one"] == "fat"
assert "field_three" in tiddler.fields
assert "field_two" in tiddler.fields
store = Store(
"tiddlywebplugins.mappingsql",
{"db_config": "sqlite:///test.db"},
{"tiddlyweb.config": config, "tiddlyweb.usersign": {"name": u"GUEST"}},
)
tiddler = Tiddler("monkey", "avox")
tiddler = store.get(tiddler)
assert tiddler.fields["field_one"] == "fat"
assert "field_three" not in tiddler.fields
assert "field_two" not in tiddler.fields
示例4: get_request
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def get_request(environ, start_response):
query = environ["tiddlyweb.query"]
tiddler_count = query.get("tiddlers", [default_tiddler_count])[0]
store = Storage("datagenerator", {})
bag = Bag(str(tiddler_count))
bag = store.get(bag)
# populate tiddlers in bag
for tiddler in bag.list_tiddlers():
store.get(tiddler)
return send_tiddlers(environ, start_response, bag)
示例5: test_get_tiddler_revision
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_get_tiddler_revision():
_cleanup()
config = { "server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
"instance_tiddlers": {
"myBag": ["%s/alpha/index.recipe" % REPO_DIR]
},
"root_dir": ""
}
env = { "tiddlyweb.config": config }
store = Store(config["server_store"][0], config["server_store"][1], env)
tiddler = Tiddler("lorem")
tiddler.bag = "myBag"
t = store.get(tiddler)
assert t.title == "lorem"
assert t.bag == "myBag"
assert t.revision == 1
assert t.tags == []
assert t.creator == "FND"
assert t.modifier == "FND"
assert len(t.created) == 14
assert len(t.modified) == 14
assert t.created == t.modified
assert t.text == "lorem ipsum"
tiddler = Tiddler("hello world")
tiddler.bag = "myBag"
tiddler.tags = ["foo", "bar"]
tiddler.modifier = "FND"
tiddler.text = "lorem ipsum"
store.put(tiddler)
tiddler = Tiddler("hello world")
tiddler.bag = "myBag"
t = store.get(tiddler)
assert t.title == "hello world"
assert t.bag == "myBag"
assert t.revision == 1
assert t.tags == ["foo", "bar"]
assert t.creator == "FND"
assert t.modifier == "FND"
assert len(t.created) == 14
assert len(t.modified) == 14
assert t.created == t.modified
assert t.text == "lorem ipsum"
示例6: test_bag_get
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_bag_get():
store = Store('tiddlywebplugins.mappingsql', {'db_config': 'sqlite:///test.db'}, {'tiddlyweb.config': config})
bag = Bag('avox')
assert len(bag.list_tiddlers()) == 0
bag = store.get(bag)
assert len(bag.list_tiddlers()) == 1
assert "NONE" in bag.policy.write
示例7: test_bag_get
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_bag_get():
store = Store("tiddlywebplugins.mappingsql", {"db_config": "sqlite:///test.db"}, {"tiddlyweb.config": config})
bag = Bag("avox")
assert len(list(store.list_bag_tiddlers(bag))) == 1
bag = store.get(bag)
assert len(list(store.list_bag_tiddlers(bag))) == 1
assert "NONE" in bag.policy.write
示例8: profile_listing_tiddlers
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def profile_listing_tiddlers():
store = Store('text', environ=environ)
environ['tiddlyweb.store'] = store
bag = Bag('profiler')
bag.skinny = True
store.get(bag)
print 'filter', time()
filter_string = 'select=tag:100'
filters, leftovers = parse_for_filters(filter_string, environ)
tiddlers = control.filter_tiddlers_from_bag(bag, filters)
print 'tmp bag', time()
tmp_bag = Bag('tmp_bag', tmpbag=True)
tmp_bag.add_tiddlers(tiddlers)
print 'output', time()
print [tiddler.title for tiddler in control.get_tiddlers_from_bag(tmp_bag)]
示例9: test_put_tiddler_to_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_put_tiddler_to_store():
_cleanup()
config = {
"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
"instance_tiddlers": {
"myBag": ["%s/alpha/index.recipe" % REPO_DIR]
},
"root_dir": ""
}
env = { "tiddlyweb.config": config }
store = Store(config["server_store"][0], config["server_store"][1], env)
tiddler = Tiddler("lorem")
tiddler.bag = "myBag"
store.put(tiddler)
tiddler_path = os.path.join(STORE_DIR, tiddler.bag, "%s.tid" % tiddler.title)
assert os.path.exists(tiddler_path)
tiddler = Tiddler("foo bar")
tiddler.bag = "myBag"
store.put(tiddler)
tiddler_path = os.path.join(STORE_DIR, "myBag", "foo%20bar.tid")
assert os.path.exists(tiddler_path)
assert store.get(tiddler).title == "foo bar"
# XXX: testing get operation here for convenience
bag = Bag("myBag")
try:
assert "foo bar" in [t.title for t in store.list_bag_tiddlers(bag)]
except AttributeError: # TiddlyWeb 1.0 has no list_bag_tiddlers method
pass
tiddler = Tiddler("foo/bar")
tiddler.bag = "myBag"
store.put(tiddler)
tiddler_path = os.path.join(STORE_DIR, "myBag", "foo%2Fbar.tid")
assert os.path.exists(tiddler_path)
assert store.get(tiddler).title == "foo/bar"
示例10: TestInstance
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
class TestInstance(object):
def setup_method(self, module):
env = { 'tiddlyweb.config': config }
self.store = Store(config['server_store'][0], config['server_store'][1], environ=env)
def teardown_method(self, module):
os.chdir('..')
rmtree(instance_dir)
def test_create_tiddlywebwiki_instance(self):
spawn(instance_dir, config, instance_module)
contents = _get_file_contents('../%s/tiddlywebconfig.py' % instance_dir)
assert "'system_plugins': ['tiddlywebwiki']" in contents
assert "'twanager_plugins': ['tiddlywebwiki']" in contents
def test_create_bag_policies(self):
spawn(instance_dir, config, instance_module)
bag = Bag('system')
system_policy = self.store.get(bag).policy
bag = Bag('common')
common_policy = self.store.get(bag).policy
assert system_policy.read == []
assert system_policy.write == ['R:ADMIN']
assert system_policy.create == ['R:ADMIN']
assert system_policy.manage == ['R:ADMIN']
assert system_policy.accept == ['R:ADMIN']
assert system_policy.delete == ['R:ADMIN']
assert common_policy.read == []
assert common_policy.write == []
assert common_policy.create == []
assert common_policy.manage == ['R:ADMIN']
assert common_policy.accept == []
assert common_policy.delete == []
示例11: profile_listing_tiddlers
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def profile_listing_tiddlers():
store = Store('text', environ=environ)
bag = Bag('profiler')
store.get(bag)
print 'filter', time()
#filter_string = '[sort[modified]]'
filter_string = ''
tiddlers = control.filter_tiddlers_from_bag(bag, filter_string)
print 'tmp bag', time()
tmp_bag = Bag('tmp_bag', tmpbag=True)
tmp_bag.add_tiddlers(tiddlers)
#print 'output', time()
#print ['.' for tiddler in control.get_tiddlers_from_bag(tmp_bag)]
print 'serializer', time()
serializer = Serializer('wiki', environ)
print 'wikify', time()
output = serializer.list_tiddlers(tmp_bag)
print 'done', time()
示例12: update_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def update_store(self):
"""
prepopulates/updates store contents by (re)importing instance_tiddlers
"""
cwd = os.getcwd()
os.chdir(self.root)
store = get_store(self.init_config)
for package_name in self.init_config['instance_pkgstores']:
source_store = Store('tiddlywebplugins.pkgstore',
{'package': package_name, 'read_only': True},
{'tiddlyweb.config': self.init_config})
for bag in source_store.list_bags():
for tiddler in source_store.list_bag_tiddlers(bag):
tiddler = source_store.get(tiddler)
store.put(tiddler)
os.chdir(cwd)
示例13: test_get_bag_from_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_get_bag_from_store():
_cleanup()
config = {
"server_store": ["tiddlywebplugins.devstore", {"store_root": STORE_DIR}],
"instance_tiddlers": {"myBag": ["%s/alpha/index.recipe" % REPO_DIR]},
"root_dir": "",
}
env = {"tiddlyweb.config": config}
store = Store(config["server_store"][0], config["server_store"][1], env)
bag = Bag("myBag")
bag = store.get(bag)
assert bag.name == "myBag"
actual = [tiddler.title for tiddler in bag.list_tiddlers()]
expected = ["SiteTitle", "foo", "lorem"]
assert sorted(actual) == sorted(expected)
示例14: test_recipe_get_from_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
def test_recipe_get_from_store():
_cleanup()
config = {
"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
"instance_tiddlers": {},
"root_dir": ""
}
env = { "tiddlyweb.config": config }
store = Store(config["server_store"][0], config["server_store"][1], env)
name = "foo"
recipe = Recipe(name)
recipe.desc = "lorem ipsum"
store.put(recipe)
recipe = Recipe(name)
recipe = store.get(recipe)
assert recipe.name == "foo"
assert recipe.desc == "lorem ipsum"
示例15: Store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import get [as 别名]
class Store(StorageInterface):
def __init__(self, environ=None):
if environ is None:
environ = {}
self.environ = environ
internal_store_environ = {
'tiddlyweb.config': {
'server_store': config['cached_store'],
}
}
self.cached_store = StoreBoss('text', environ=internal_store_environ)
def recipe_delete(self, recipe):
key = _recipe_key(recipe)
MC.delete(key)
self.cached_store.delete(recipe)
def recipe_get(self, recipe):
key = _recipe_key(recipe)
cached_recipe = _get(key)
if cached_recipe:
recipe = cached_recipe
else:
recipe = self.cached_store.get(recipe)
MC.set(key, recipe)
return recipe
def recipe_put(self, recipe):
key = _recipe_key(recipe)
self.cached_store.put(recipe)
MC.delete(key)
def bag_delete(self, bag):
key = _bag_key(bag)
if MC.delete(key):
MC.delete_multi([_tiddler_key(tiddler) for tiddler in bag.list_tiddlers()])
self.cached_store.delete(bag)
def bag_get(self, bag):
key = _bag_key(bag)
cached_bag = _get(key)
if cached_bag:
bag = cached_bag
else:
bag = self.cached_store.get(bag)
MC.set(key, bag)
return bag
def bag_put(self, bag):
key = _bag_key(bag)
self.cached_store.put(bag)
MC.delete(key)
def tiddler_delete(self, tiddler):
key = _tiddler_key(tiddler)
if MC.delete(key):
MC.delete(_bag_key(Bag(tiddler.bag)))
self.cached_store.delete(tiddler)
def tiddler_get(self, tiddler):
key = _tiddler_key(tiddler)
if not tiddler.revision or tiddler.revision == 0:
cached_tiddler = _get(key)
if cached_tiddler:
tiddler = cached_tiddler
else:
tiddler = self.cached_store.get(tiddler)
MC.set(key, tiddler)
else:
tiddler = self.cached_store.get(tiddler)
return tiddler
def tiddler_put(self, tiddler):
key = _tiddler_key(tiddler)
self.cached_store.put(tiddler)
MC.delete(_bag_key(Bag(tiddler.bag)))
MC.delete(key)
def user_delete(self, user):
key = _user_key(user)
MC.delete(key)
self.cached_store.delete(user)
def user_get(self, user):
key = _user_key(user)
cached_user = _get(key)
if cached_user:
user = cached_user
else:
user = self.cached_store.get(user)
MC.set(key, user)
return user
def user_put(self, user):
key = _user_key(user)
self.cached_store.put(user)
MC.delete(key)
#.........这里部分代码省略.........