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


Python Store.get方法代码示例

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

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

示例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
开发者ID:palladius,项目名称:appengine,代码行数:31,代码来源:test_simple.py

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

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

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

示例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
开发者ID:palladius,项目名称:appengine,代码行数:10,代码来源:test_simple.py

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

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

示例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 == []
开发者ID:FND,项目名称:tiddlywebwiki,代码行数:41,代码来源:test_manage.py

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

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

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

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

示例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)

#.........这里部分代码省略.........
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:103,代码来源:caching.py


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