本文整理汇总了Python中tiddlywebplugins.utils.get_store函数的典型用法代码示例。如果您正苦于以下问题:Python get_store函数的具体用法?Python get_store怎么用?Python get_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_store函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_module
def setup_module(module):
module.store = get_store(config)
module.environ = {"tiddlyweb.config": config, "tiddlyweb.store": module.store}
session = module.store.storage.session
# delete everything
Base.metadata.drop_all()
Base.metadata.create_all()
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.sqlalchemy,代码行数:7,代码来源:test_search.py
示例2: test_cookie_set
def test_cookie_set():
"""
test that we get a cookie relating to the space we are in
"""
store = get_store(config)
hostname = "foo.0.0.0.0:8080"
user = User(u"f\u00F6o")
user.set_password("foobar")
store.put(user)
user_cookie = get_auth(u"f\u00F6o", "foobar")
response, content = http.request(
"http://foo.0.0.0.0:8080/", method="GET", headers={"Cookie": 'tiddlyweb_user="%s"' % user_cookie}
)
assert response["status"] == "200", content
time = datetime.utcnow().strftime("%Y%m%d%H")
cookie = "csrf_token=%s:%s:%s" % (
time,
user.usersign,
sha("%s:%s:%s:%s" % (user.usersign, time, hostname, config["secret"])).hexdigest(),
)
assert response["set-cookie"] == quote(cookie.encode("utf-8"), safe=".!~*'():=")
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.csrf,代码行数:25,代码来源:test_post_validate.py
示例3: url
def url(args):
"""Add a URL via tiddlywebplugins.URLs. Redirect is optional. [--redirect] <selector_path> <destination_url>"""
if 2 != len(args) != 3:
print >> sys.stderr, ('you must include both the path you want to use (selector path) and the destination url')
store = get_store(config)
if args[0] == '--redirect':
redirect = args.pop(0).lstrip('-')
else:
redirect = None
selector_path = args[0]
destination_url = args[1]
tiddler = Tiddler(selector_path)
tiddler.bag = config['url_bag']
tiddler.text = destination_url
if redirect:
tiddler.tags = [redirect]
if validate_url(tiddler):
store.put(tiddler)
return True
开发者ID:bengillies,项目名称:tiddlywebplugins.urls,代码行数:26,代码来源:twanager.py
示例4: init
def init(config):
"""
init function for tiddlywebpages.
Set URLs
define serializers
"""
merge_config(config, twp_config)
# provide a way to allow people to refresh their URLs
config["selector"].add("/tiddlywebpages/refresh", GET=refresh)
# get the store
store = get_store(config)
# set the default config info
BAG_OF_TEMPLATES = config["tw_pages"]["template_bag"]
if "config" in config["tw_pages"]:
register_config(config, store)
for new_filter in config["tw_pages"]["filters"]:
_temp = __import__(new_filter, {}, {}, [new_filter])
TW_PAGES_FILTERS.append((new_filter, getattr(_temp, new_filter)))
if "config" in config["tw_pages"]:
register_config(config, store)
register_templates(config, store)
开发者ID:bengillies,项目名称:TiddlyWeb-Plugins,代码行数:27,代码来源:__init__.py
示例5: retrieve_from_store
def retrieve_from_store(email):
"""
get the tiddler requested by the email from the store
and return it as an email
"""
store = get_store(config)
tiddler_title = clean_subject(email["subject"])
tiddler = Tiddler(tiddler_title)
bag = determine_bag(email["to"])
tiddler.bag = bag
try:
tiddler = store.get(tiddler)
response_text = tiddler.text
except NoTiddlerError:
# Tiddler not found. Return a list of all tiddlers
bag = Bag(bag)
bag = store.get(bag)
response_text = "The following tiddlers are in %s:\n" % email["to"].split("@")[1]
tiddlers = bag.gen_tiddlers()
tiddlers = [tiddler for tiddler in tiddlers]
response_text += "\n".join([tiddler.title for tiddler in tiddlers])
response_email = {"from": email["to"], "to": email["from"], "subject": tiddler.title, "body": response_text}
return response_email
开发者ID:jdlrobson,项目名称:tiddlywebplugins.email,代码行数:26,代码来源:mail.py
示例6: setup_module
def setup_module(module):
if os.path.exists('store'):
shutil.rmtree('store')
init(config)
module.savedin = sys.stdin
module.store = get_store(config)
module.store.put(Bag('bag1'))
开发者ID:bengillies,项目名称:tiddlywebplugins.csv,代码行数:7,代码来源:test_import_csv.py
示例7: twimport
def twimport(args):
"""Import tiddlers, recipes, wikis, binary content: <bag> <URI>"""
bag = args[0]
urls = args[1:]
if not bag or not urls:
raise IndexError('missing args')
import_list(bag, urls, get_store(config))
开发者ID:bengillies,项目名称:tiddlywebplugins.twimport,代码行数:7,代码来源:twimport.py
示例8: make_subscription
def make_subscription(email):
"""
add somebody to a subscription
"""
store = get_store(config)
recipe = determine_bag(email['to'])
fromAddress = email['from']
subscription_bag = get_subscriptions_bag(store)
subscribers_tiddler = Tiddler('bags/%s/tiddlers' % recipe, subscription_bag)
try:
subscribers_tiddler = store.get(subscribers_tiddler)
subscriber_emails = subscribers_tiddler.text.splitlines()
if fromAddress not in subscriber_emails:
subscriber_emails.append(fromAddress)
subscribers_tiddler.text = '\n'.join(subscriber_emails)
store.put(subscribers_tiddler)
except NoTiddlerError:
subscribers_tiddler.text = fromAddress
store.put(subscribers_tiddler)
return {'from': email['to'],
'to': email['from'],
'subject': 'You have subscribed to %s' % recipe,
'body': 'You will now receive daily digests. To unsubscribe please email [email protected]%s'
}
开发者ID:bengillies,项目名称:tiddlywebplugins.email,代码行数:25,代码来源:subscriptions.py
示例9: setup_module
def setup_module(module):
try:
shutil.rmtree('indexdir')
shutil.rmtree('store')
except:
pass
app = load_app()
def app_fn(): return app
requests_intercept.install()
wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn)
store = get_store(config)
test_bag1 = Bag('newtank')
try:
store.delete(test_bag1)
except StoreError:
pass
test_bag1.policy.accept = ['NONE']
store.put(test_bag1)
module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config}
module.store = store
module.cookie, module.csrf = establish_user_auth(config, store,
'tankt.peermore.com:8080', 'tester')
开发者ID:BillSeitz,项目名称:tank,代码行数:27,代码来源:test_closet.py
示例10: determine_entries
def determine_entries(environ):
"""
returns descendant resources based on the WSGI environment
"""
candidates = { # XXX: hard-coded; ideally descendants should be determined via HATEOAS-y clues
"[/]": lambda *args: [Collection("/bags"), Collection("/recipes")],
"/bags[.{format}]": _bags,
"/recipes[.{format}]": _recipes,
"/bags/{bag_name:segment}/tiddlers[.{format}]": _tiddlers
}
current_uri = environ["SCRIPT_NAME"]
config = environ["tiddlyweb.config"]
store = get_store(config)
router = Router(mapfile=config["urls_map"], prefix=config["server_prefix"]) # XXX: does not support extensions
for regex, supported_methods in router.mappings:
if regex.search(current_uri): # matching route
pattern = router.routes[regex]
descendants = candidates[pattern]
routing_args = environ["wsgiorg.routing_args"]
descendants = descendants(store, *routing_args[0], **routing_args[1])
break
return chain([Collection(current_uri)], descendants)
开发者ID:FND,项目名称:tiddlywebplugins.webdav,代码行数:25,代码来源:collections.py
示例11: setup_module
def setup_module(module):
try:
shutil.rmtree('store')
except:
pass
config['markdown.wiki_link_base'] = ''
store = get_store(config)
environ['tiddlyweb.store'] = store
store.put(Bag('bag'))
module.store = store
recipe = Recipe('recipe_public')
recipe.set_recipe([('bag', '')])
store.put(recipe)
tiddlerA = Tiddler('tiddler a', 'bag')
tiddlerA.text = 'I am _tiddler_'
store.put(tiddlerA)
tiddlerB = Tiddler('tiddler b')
tiddlerB.text = '''
You wish
{{tiddler a}}
And I wish too.
'''
module.tiddlerB = tiddlerB
开发者ID:FND,项目名称:tiddlywebplugins.markdown,代码行数:30,代码来源:test_transclusion.py
示例12: _init_store
def _init_store(self, struct):
"""
creates basic store structure with bags, recipes and users
(no support for user passwords for security reasons)
"""
store = get_store(self.init_config)
bags = struct.get("bags", {})
for name, data in bags.items():
desc = data.get("desc")
bag = Bag(name, desc=desc)
constraints = data.get("policy", {})
_set_policy(bag, constraints)
store.put(bag)
recipes = struct.get("recipes", {})
for name, data in recipes.items(): # TODO: DRY
desc = data.get("desc")
recipe = Recipe(name, desc=desc)
recipe.set_recipe(data["recipe"])
constraints = data.get("policy", {})
_set_policy(recipe, constraints)
store.put(recipe)
users = struct.get("users", {})
for name, data in users.items():
note = data.get("note")
user = User(name, note=note)
password = data.get("_password")
if password:
user.set_password(password)
for role in data.get("roles", []):
user.add_role(role)
store.put(user)
开发者ID:FND,项目名称:tiddlywebplugins.imaker,代码行数:35,代码来源:imaker.py
示例13: setup_store
def setup_store():
"""
initialise a blank store, and fill it with some data
"""
store = get_store(config)
for bag in BAGS:
bag = Bag(bag)
try:
store.delete(bag)
except NoBagError:
pass
store.put(bag)
for recipe, contents in RECIPES.iteritems():
recipe = Recipe(recipe)
try:
store.delete(recipe)
except NoRecipeError:
pass
recipe.set_recipe(contents)
store.put(recipe)
return store
开发者ID:jdlrobson,项目名称:tiddlywebplugins.form,代码行数:25,代码来源:setup_test.py
示例14: wreindex
def wreindex(args):
"""Rebuild the entire whoosh index."""
try:
prefix = args[0]
except IndexError:
prefix = None
store = get_store(config)
schema = config.get('wsearch.schema',
SEARCH_DEFAULTS['wsearch.schema'])
if __name__ in config.get('beanstalk.listeners', []):
_reindex_async(config)
else:
for bag in store.list_bags():
bag = store.get(bag)
writer = get_writer(config)
if writer:
try:
try:
tiddlers = bag.get_tiddlers()
except AttributeError:
tiddlers = store.list_bag_tiddlers(bag)
for tiddler in tiddlers:
if prefix and not tiddler.title.startswith(prefix):
continue
tiddler = store.get(tiddler)
index_tiddler(tiddler, schema, writer)
writer.commit()
except:
LOGGER.debug('whoosher: exception while indexing: %s',
format_exc())
writer.cancel()
else:
LOGGER.debug('whoosher: unable to get writer '
'(locked) for %s', bag.name)
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.whoosher,代码行数:34,代码来源:whoosher.py
示例15: test_cookie_set
def test_cookie_set():
"""
test that we get a cookie relating to the space we are in
"""
store = get_store(config)
space = 'foo'
make_fake_space(store, space)
user = User('foo')
user.set_password('foobar')
store.put(user)
user_cookie = get_auth('foo', 'foobar')
response, content = http.request('http://foo.0.0.0.0:8080/status',
method='GET',
headers={
'Cookie': 'tiddlyweb_user="%s"' % user_cookie
})
assert response['status'] == '200', content
time = datetime.now().strftime('%Y%m%d%H')
cookie = 'csrf_token=%s:%s:%s' % (time, user.usersign,
sha('%s:%s:%s:%s' % (user.usersign,
time, space, config['secret'])).hexdigest())
assert response['set-cookie'] == cookie
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:26,代码来源:test_post_validate.py
示例16: setup_module
def setup_module(module):
try:
shutil.rmtree('indexdir')
shutil.rmtree('store')
except:
pass
app = load_app()
def app_fn(): return app
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn)
store = get_store(config)
test_bag = Bag('editable')
try:
store.delete(test_bag)
except StoreError:
pass
store.put(test_bag)
module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config}
module.store = store
module.http = httplib2.Http()
module.csrf = None
开发者ID:BillSeitz,项目名称:tank,代码行数:27,代码来源:test_edit.py
示例17: setup_module
def setup_module(module):
"""
clean up the store, establish a registered client
"""
clean_store()
module.store = get_store(config)
environ = {'tiddlyweb.config': config, 'tiddlyweb.store': module.store}
ensure_bags(config)
# make an application and store that info
app = create(name='testapp', owner='appowner1',
app_url='http://our_test_domain:8001',
callback_url='http://our_test_domain:8001/_oauth/callback')
client_id = app.title
client_secret = app.fields['client_secret']
store_app(environ, app)
config['oauth.servers']['testserver']['client_id'] = client_id
config['oauth.servers']['testserver']['client_secret'] = client_secret
module.client_id = client_id
initialize_app(config)
module.http = Http()
# we need a user who is going to use the client app
user = User('cdent')
user.set_password('cowpig')
module.store.put(user)
开发者ID:cdent,项目名称:tiddlywebplugins.oauth,代码行数:31,代码来源:test_consumer.py
示例18: delete_subscription
def delete_subscription(email):
"""
remove somebody from a particular subscription
"""
store = get_store(config)
recipe = determine_bag(email['to'])
fromAddress = email['from']
subscription_bag = get_subscriptions_bag(store)
try:
subscribers_tiddler = store.get(Tiddler('bags/%s/tiddlers' % recipe, subscription_bag))
subscriber_emails = subscribers_tiddler.text.splitlines()
try:
subscriber_emails.remove(fromAddress)
except ValueError:
pass
subscribers_tiddler.text = '\n'.join(subscriber_emails)
store.put(subscribers_tiddler)
except NoTiddlerError:
pass
return {'from': email['to'],
'to': email['from'],
'subject': 'You have been unsubscribed from %s' % recipe,
'body': 'Harry the dog is currently whining in sadness.'
}
开发者ID:bengillies,项目名称:tiddlywebplugins.email,代码行数:27,代码来源:subscriptions.py
示例19: setup_module
def setup_module(module):
module.TMPDIR = tempfile.mkdtemp()
_initialize_app(TMPDIR)
module.ADMIN_COOKIE = make_cookie('tiddlyweb_user', 'admin',
mac_key=CONFIG['secret'])
module.STORE = get_store(CONFIG)
# register admin user
data = {
'username': 'admin',
'password': 'secret',
'password_confirmation': 'secret'
}
response, content = _req('POST', '/register', urlencode(data),
headers={ 'Content-Type': 'application/x-www-form-urlencoded' })
bag = Bag('alpha')
bag.policy = Policy(read=['admin'], write=['admin'], create=['admin'],
delete=['admin'], manage=['admin'])
STORE.put(bag)
bag = Bag('bravo')
STORE.put(bag)
bag = Bag('charlie')
bag.policy = Policy(read=['nobody'], write=['nobody'], create=['nobody'],
delete=['nobody'], manage=['nobody'])
STORE.put(bag)
tiddler = Tiddler('index', 'bravo')
tiddler.text = 'lorem ipsum\ndolor *sit* amet'
tiddler.type = 'text/x-markdown'
STORE.put(tiddler)
开发者ID:pads,项目名称:tiddlywebplugins.bfw,代码行数:35,代码来源:test_web.py
示例20: test_validator_nonce_fail
def test_validator_nonce_fail():
"""
test the validator directly
ensure that it fails when the nonce doesn't match
"""
store = get_store(config)
nonce = 'dwaoiju277218ywdhdnakas72'
username = 'foo'
spacename = 'foo'
secret = '12345'
timestamp = datetime.now().strftime('%Y%m%d%H')
environ = {
'tiddlyweb.usersign': {'name': username},
'tiddlyweb.config': {
'secret': secret,
'server_host': {
'host': '0.0.0.0',
'port': '8080'
}
},
'HTTP_HOST': 'foo.0.0.0.0:8080'
}
make_fake_space(store, spacename)
try:
csrf = CSRFProtector({})
result = csrf.check_csrf(environ, nonce)
raise AssertionError('check_csrf succeeded when nonce didn\'t match')
except InvalidNonceError, exc:
assert exc.message == BAD_MATCH_MESSAGE
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:30,代码来源:test_post_validate.py
注:本文中的tiddlywebplugins.utils.get_store函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论