本文整理汇总了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)
示例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('..')
示例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()
示例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
示例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)
示例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
示例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
示例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)
示例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]
示例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')
示例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
示例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"]
示例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)
示例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))
示例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()