本文整理汇总了Python中tiddlyweb.store.Store.put方法的典型用法代码示例。如果您正苦于以下问题:Python Store.put方法的具体用法?Python Store.put怎么用?Python Store.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.store.Store
的用法示例。
在下文中一共展示了Store.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_recipe
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def _make_recipe(recipe_name, bags):
"""Make a recipe with recipe_name."""
recipe = Recipe(recipe_name)
recipe_list = [[bag, ''] for bag in bags]
recipe.set_recipe(recipe_list)
store = Store(config['server_store'][0], environ={'tiddlyweb.config': config})
store.put(recipe)
示例2: cache_tiddlers
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def cache_tiddlers(package_name):
"""
Stores instance tiddlers in the package.
reads store_contents from <package>.instance
tiddler files are stored in <package>/resources/store
"""
instance_module = __import__('%s.instance' % package_name, None, None,
['instance'])
store_contents = instance_module.store_contents
target_store = Store('tiddlywebplugins.pkgstore',
{'package': package_name, 'read_only': False}, {})
sources = {}
for bag, uris in store_contents.items():
sources[bag] = []
for uri in uris:
if uri.endswith('.recipe'):
urls = recipe_to_urls(uri)
sources[bag].extend(urls)
else:
sources[bag].append(uri)
for bag_name, uris in sources.items():
bag = Bag(bag_name)
target_store.put(bag)
for uri in uris:
std_error_message('retrieving %s' % uri)
tiddler = url_to_tiddler(uri)
tiddler.bag = bag.name
target_store.put(tiddler)
示例3: setup_module
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def setup_module(module):
# cleanup
try:
shutil.rmtree('store')
except OSError:
pass
# establish web server
app = load_app()
def app_fn():
return app
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
# establish store
store = Store(config['server_store'][0], config['server_store'][1],
environ={'tiddlyweb.config': config})
# make some stuff
bag = Bag('place')
store.put(bag)
for i in range(1, 10):
tiddler = Tiddler('tiddler%s' % i, 'place')
tiddler.text = 'hi%s'
store.put(tiddler)
module.http = httplib2.Http()
示例4: make_tiddlers_for_bag
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def make_tiddlers_for_bag():
store = Store('text', environ=environ)
print 'store', time()
bag = Bag('profiler')
store.put(bag)
for name in range(1, 1000):
name = str(name)
tiddler = Tiddler(name, bag.name)
tiddler.text = name
store.put(tiddler)
示例5: test_where_it_goes
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def test_where_it_goes():
store = Store(SAMPLE_CONFIG['server_store'][0],
SAMPLE_CONFIG['server_store'][1],
environ=ENVIRON)
bbag = Bag('bbag')
cbag = Bag('cbag')
store.put(bbag)
store.put(cbag)
assert os.path.exists('store1/bags/bbag/tiddlers')
assert os.path.exists('store2/bags/cbag/tiddlers')
assert not os.path.exists('store2/bags/bbag/tiddlers')
assert not os.path.exists('store1/bags/cbag/tiddlers')
示例6: setup_module
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def setup_module(module):
bag = Bag('holder')
store = Store(config['server_store'][0], config['server_store'][1],
{'tiddlyweb.config': config})
store.put(bag)
import_one('holder', IMAGE, store)
import_one('holder', ZERO, store)
tiddler = Tiddler('index', 'holder')
tiddler.text = open(HTML).read().decode('UTF-8')
tiddler.type = 'text/html'
store.put(tiddler)
module.store = store
示例7: make_tiddlers_for_bag
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def make_tiddlers_for_bag():
store = Store('text', environ['tiddlyweb.config']['server_store'][1], environ)
print 'store', time()
bag = Bag('profiler')
store.put(bag)
for name in range(1, 10000):
tag = name % 10
name = str(name)
tag = str(tag)
tiddler = Tiddler(name, bag.name)
tiddler.text = name
tiddler.tags.append(tag)
store.put(tiddler)
print 'stored', time()
示例8: test_recipe_put_to_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def test_recipe_put_to_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)
store.put(recipe)
assert os.path.exists("%s.recipe" % os.path.join(STORE_DIR, name))
示例9: test_get_tiddler_revision
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [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"
示例10: test_recipe_delete_from_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def test_recipe_delete_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)
store.delete(recipe)
recipe = Recipe(name)
raises(NoRecipeError, "store.get(recipe)")
示例11: test_serialization
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def test_serialization():
_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)
f = open("%s.recipe" % os.path.join(STORE_DIR, name))
actual = f.read()
f.close()
expected = """desc: lorem ipsum
policy: {"read": [], "create": [], "manage": [], "accept": [], "write": [], "owner": null, "delete": []}
"""
assert actual == expected
示例12: test_basic_search_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def test_basic_search_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)
bagone = Bag('bagone')
bagtwo = Bag('bagtwo')
tiddler1 = Tiddler('tiddler1', 'bagone')
tiddler2 = Tiddler('tiddler2', 'bagtwo')
tiddler1.text = tiddler2.text = 'ohhai'
store.put(bagone)
store.put(bagtwo)
store.put(tiddler1)
store.put(tiddler2)
tiddlers = list(store.search('ohhai'))
assert len(tiddlers) == 2
assert ['tiddler1', 'tiddler2'] == sorted([tiddler.title for tiddler in tiddlers])
示例13: setup_module
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def setup_module(module):
# cleanup
try:
shutil.rmtree("store")
except OSError:
pass
# establish web server
app = load_app()
def app_fn():
return app
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept("our_test_domain", 8001, app_fn)
# establish store
store = Store(config["server_store"][0], config["server_store"][1], environ={"tiddlyweb.config": config})
# make some stuff
bag = Bag("place")
store.put(bag)
recipe = Recipe("plaice")
recipe.set_recipe([("place", "")])
store.put(recipe)
tiddler = Tiddler("one", "place")
tiddler.text = "hi"
store.put(tiddler)
tiddler = Tiddler("two", "place")
tiddler.tags = ["tagged"]
tiddler.text = "hi"
store.put(tiddler)
module.store = store
# module.http = httplib2.Http('.test_cache')
module.http = httplib2.Http()
示例14: test_put_tiddler_to_store
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [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"
示例15: _make_bag
# 需要导入模块: from tiddlyweb.store import Store [as 别名]
# 或者: from tiddlyweb.store.Store import put [as 别名]
def _make_bag(bag_name):
"""Make a bag with name bag_name to the store."""
bag = Bag(bag_name)
store = Store(config['server_store'][0], environ={'tiddlyweb.config': config})
store.put(bag)