当前位置: 首页>>代码示例>>Python>>正文


Python Store.put方法代码示例

本文整理汇总了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)
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:9,代码来源:instancer.py

示例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)
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.ibuilder,代码行数:36,代码来源:ibuilder.py

示例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()
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.etagcache,代码行数:29,代码来源:test_stress.py

示例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)
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:14,代码来源:list_tiddlers.py

示例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')
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:15,代码来源:test_dist.py

示例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
开发者ID:tiddlyweb,项目名称:tiddlywebwiki,代码行数:16,代码来源:test_serialize_binary.py

示例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()
开发者ID:24king,项目名称:tiddlyweb,代码行数:18,代码来源:list_tiddlers.py

示例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))
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:18,代码来源:test_recipe_put.py

示例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"
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:49,代码来源:test_tiddler_get.py

示例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)")
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:23,代码来源:test_recipe_delete.py

示例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
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:25,代码来源:test_recipe_put.py

示例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])
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:26,代码来源:test_search.py

示例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()
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.etagcache,代码行数:41,代码来源:test_web.py

示例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"
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:44,代码来源:test_tiddler_put.py

示例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)
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:7,代码来源:instancer.py


注:本文中的tiddlyweb.store.Store.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。