當前位置: 首頁>>代碼示例>>Python>>正文


Python store.Store類代碼示例

本文整理匯總了Python中tiddlyweb.store.Store的典型用法代碼示例。如果您正苦於以下問題:Python Store類的具體用法?Python Store怎麽用?Python Store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Store類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cache_tiddlers

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,代碼行數:34,代碼來源:ibuilder.py

示例2: test_create_bag_policies

    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,代碼行數:25,代碼來源:test_manage.py

示例3: setup_module

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,代碼行數:27,代碼來源:test_stress.py

示例4: __init__

 def __init__(self, store_config=None, environ=None):
     super(Store, self).__init__(store_config, environ)
     self.config = environ.get('tiddlyweb.config')
     self.binary_store = StoreBoss('text', {'store_root': 'binarystore'},
             environ=environ).storage
     self.core_store = StoreBoss(self.config['binarystore.child'][0],
             self.config['binarystore.child'][1], environ=environ).storage
開發者ID:cdent,項目名稱:tiddlywebplugins.binarystore,代碼行數:7,代碼來源:binarystore.py

示例5: _make_recipe

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,代碼行數:7,代碼來源:instancer.py

示例6: test_bag_get

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,代碼行數:8,代碼來源:test_simple.py

示例7: test_bag_get

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,代碼行數:8,代碼來源:test_simple.py

示例8: make_tiddlers_for_bag

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,代碼行數:12,代碼來源:list_tiddlers.py

示例9: profile_listing_tiddlers

def profile_listing_tiddlers():
    store = Store('text', environ['tiddlyweb.config']['server_store'][1], environ)
    environ['tiddlyweb.store'] = store

    bag = Bag('profiler')

    print 'filter', time()
    filter_string = 'select=tag:1'
    filters, leftovers = parse_for_filters(filter_string, environ)
    tiddlers = control.filter_tiddlers(store.list_bag_tiddlers(bag), filters, environ=environ)

    print 'output', time()
    print [tiddler.title for tiddler in tiddlers]
開發者ID:24king,項目名稱:tiddlyweb,代碼行數:13,代碼來源:list_tiddlers.py

示例10: test_where_it_goes

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,代碼行數:13,代碼來源:test_dist.py

示例11: setup_module

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,代碼行數:14,代碼來源:test_serialize_binary.py

示例12: __init__

    def __init__(self, store_config=None, environ=None):
        if store_config is None:
            store_config = {}
        if environ is None:
            environ = {}
        self.environ = environ
        self.config = environ.get("tiddlyweb.config")

        self._mc = self._MC

        if self._mc == None:
            try:
                from google.appengine.api import memcache

                self._MC = memcache
            except ImportError:
                import memcache

                try:
                    self._MC = memcache.Client(self.config["memcache_hosts"])
                except KeyError:
                    from tiddlyweb.config import config

                    self.config = config
                    self._MC = memcache.Client(self.config["memcache_hosts"])
            self._mc = self._MC

            self.cached_store = StoreBoss(
                self.config["cached_store"][0], self.config["cached_store"][1], environ=environ
            )
            self.prefix = self.config["server_prefix"]
            self.host = self.config["server_host"]["host"]
開發者ID:jdlrobson,項目名稱:tiddlyweb-plugins,代碼行數:32,代碼來源:caching.py

示例13: __init__

	def __init__(self, environ=None):
		logging.debug("initializing SSL Store")
		super(Store, self).__init__(environ)
		config = self.environ["tiddlyweb.config"]
		self.ssl_bags = config["ssl_bags"] # intentionally not providing empty fallback -- XXX: rename?
		real_store = config["server_store"][1]["store_module"] # XXX: rename? -- TODO: use pop method to keep config clean?
		self.real_store = Storage(real_store, self.environ)
開發者ID:FND,項目名稱:tiddlyweb-plugins,代碼行數:7,代碼來源:sslstore.py

示例14: test_recipe_put_to_store

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,代碼行數:16,代碼來源:test_recipe_put.py

示例15: make_tiddlers_for_bag

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,代碼行數:16,代碼來源:list_tiddlers.py


注:本文中的tiddlyweb.store.Store類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。