本文整理汇总了Python中tiddlyweb.store.Store类的典型用法代码示例。如果您正苦于以下问题:Python Store类的具体用法?Python Store怎么用?Python Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_get_tiddler_revision
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,代码行数:47,代码来源:test_tiddler_get.py
示例17: test_list_bags_in_store
def test_list_bags_in_store():
_cleanup()
config = {
"server_store": ["tiddlywebplugins.devstore", { "store_root": STORE_DIR }],
"instance_tiddlers": {
"alpha": ["%s/alpha/index.recipe" % REPO_DIR],
"bravo": ["%s/bravo/index.recipe" % REPO_DIR]
},
"root_dir": ""
}
env = { "tiddlyweb.config": config }
store = Store(config["server_store"][0], config["server_store"][1], env)
actual = [bag.name for bag in store.list_bags()]
expected = ["bravo", "alpha"]
assert sorted(actual) == sorted(expected)
开发者ID:FND,项目名称:tiddlyweb-plugins,代码行数:17,代码来源:test_bag_list.py
示例18: update_store
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,代码行数:17,代码来源:imaker.py
示例19: test_list_recipes_in_store
def test_list_recipes_in_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)
for name in ["alpha", "bravo", "charlie"]:
filepath = "%s.recipe" % os.path.join(STORE_DIR, name)
open(filepath, "w").close()
actual = [recipe.name for recipe in store.list_recipes()]
expected = ["bravo", "alpha", "charlie"]
assert set(actual) == set(expected)
开发者ID:cdent,项目名称:tiddlyweb-plugins,代码行数:18,代码来源:test_recipe_list.py
示例20: test_get_bag_from_store
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,代码行数:19,代码来源:test_bag_get.py
注:本文中的tiddlyweb.store.Store类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论