本文整理汇总了Python中tiddlyweb.model.bag.Bag.skinny方法的典型用法代码示例。如果您正苦于以下问题:Python Bag.skinny方法的具体用法?Python Bag.skinny怎么用?Python Bag.skinny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.bag.Bag
的用法示例。
在下文中一共展示了Bag.skinny方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_createbag
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def post_createbag(environ, start_response):
user = get_user_object(environ)
store = environ['tiddlyweb.store']
bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
publicity = environ['tiddlyweb.query'].get('publicity', [''])[0]
description = environ['tiddlyweb.query'].get('description', [''])[0]
if not bag_name:
raise HTTP400('missing data')
bag = Bag(bag_name)
try:
bag.skinny = True
bag = store.get(bag)
raise HTTP400('bag exists')
except NoBagError:
pass
if publicity == 'public':
bag = ensure_public_bag(
store, user['name'], desc=description, name=bag_name)
elif publicity == 'protected':
bag = ensure_protected_bag(
store, user['name'], desc=description, name=bag_name)
else:
bag = ensure_private_bag(
store, user['name'], desc=description, name=bag_name)
# the bag has already been stored
raise HTTP303('%s/tiddlers' % bag_url(environ, bag))
示例2: _process_choices
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def _process_choices(environ, start_response, form):
store = environ['tiddlyweb.store']
user = environ['tiddlyweb.usersign']
tmp_bag = form['tmp_bag'][0]
bag = form['target_bag'][0]
if bag:
bag = Bag(bag)
try:
bag.skinny = True
bag = store.get(bag)
except NoBagError:
return _send_wimport(environ, start_response,
'chosen bag does not exist')
else:
bag = form['new_bag'][0]
bag = _make_bag(environ, bag)
try:
bag.policy.allows(user, 'write')
except (ForbiddenError, UserRequiredError):
return _send_wimport(environ, start_response,
'you may not write to that bag')
tiddler_titles = form['tiddler']
for title in tiddler_titles:
tiddler = Tiddler(title.decode('utf-8', 'ignore'), tmp_bag)
tiddler = store.get(tiddler)
tiddler.bag = bag.name
store.put(tiddler)
tmp_bag = Bag(tmp_bag)
store.delete(tmp_bag)
bagurl = bag_url(environ, bag) + '/tiddlers'
raise HTTP302(bagurl)
示例3: get
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def get(environ, start_response):
"""
Perform a search on the store. What search
means and what results are returned is dependent
on the search implementation (if any) in the
chosen store.
"""
store = environ['tiddlyweb.store']
tiddlers = get_tiddlers(environ)
usersign = environ['tiddlyweb.usersign']
tmp_bag = Bag('tmp_bag', tmpbag=True, searchbag=True)
bag_readable = {}
for tiddler in tiddlers:
try:
if bag_readable[tiddler.bag]:
tmp_bag.add_tiddler(store.get(tiddler))
except KeyError:
bag = Bag(tiddler.bag)
bag.skinny = True
bag = store.get(bag)
try:
bag.policy.allows(usersign, 'read')
tmp_bag.add_tiddler(store.get(tiddler))
bag_readable[tiddler.bag] = True
except(ForbiddenError, UserRequiredError):
bag_readable[tiddler.bag] = False
return send_tiddlers(environ, start_response, tmp_bag)
示例4: _read_bag_perms
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def _read_bag_perms(environ, tiddler):
perms = []
if 'tiddlyweb.usersign' in environ:
store = tiddler.store
if store:
bag = Bag(tiddler.bag)
bag.skinny = True
bag = store.get(bag)
perms = bag.policy.user_perms(environ['tiddlyweb.usersign'])
return perms
示例5: test_put_get_bag
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def test_put_get_bag():
bag = Bag('testone')
bag.policy.read = ['cdent']
store.put(bag)
read_bag = Bag('testone')
read_bag.skinny = True
read_bag = store.get(read_bag)
assert read_bag.policy.read == ['cdent']
示例6: get_favorited_bags
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def get_favorited_bags(store, username):
favorites = get_favorites(store, username)
bags = []
for favorite in favorites:
try:
bag = Bag(favorite)
bag.skinny = True
bags.append(store.get(bag))
except NoBagError:
pass # don't care if it doesn't exist
return bags
示例7: _get_bag
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def _get_bag(environ, bag_name, skinny=False):
"""
Get the named bag out of the store.
"""
bag = Bag(bag_name)
if skinny:
bag.skinny = True
store = environ["tiddlyweb.store"]
try:
bag = store.get(bag)
except NoBagError, exc:
raise HTTP404("%s not found, %s" % (bag.name, exc))
示例8: first_time_check
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def first_time_check(environ, user):
username = user["name"]
store = environ["tiddlyweb.store"]
try:
bag = Bag(username)
bag.skinny = True
store.get(bag)
except NoBagError:
ensure_public_bag(store, username)
ensure_private_bag(store, username)
ensure_public_recipe(store, username)
ensure_private_recipe(store, username)
ensure_user_bag(store, username)
示例9: _tiddler_permissions
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def _tiddler_permissions(self, tiddler):
"""
Make a list of the permissions the current user has
on this tiddler.
"""
perms = []
bag = Bag(tiddler.bag)
if tiddler.store:
bag.skinny = True
bag = tiddler.store.get(bag)
if 'tiddlyweb.usersign' in self.environ:
perms = bag.policy.user_perms(self.environ['tiddlyweb.usersign'])
return perms
示例10: get
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def get(environ, start_response):
"""
Perform a search on the store. What search
means and what results are returned is dependent
on the search implementation (if any) in the
chosen store.
"""
try:
search_query = environ['tiddlyweb.query']['q'][0]
search_query = urllib.unquote(search_query)
search_query = unicode(search_query, 'utf-8')
except (KeyError, IndexError):
raise HTTP400('query string required')
filters = environ['tiddlyweb.filters']
store = environ['tiddlyweb.store']
try:
tiddlers = store.search(search_query)
except StoreMethodNotImplemented:
raise HTTP400('Search system not implemented')
usersign = environ['tiddlyweb.usersign']
# It's necessary to get the tiddler off the store
# in case we are doing wiki or atom outputs of the
# search.
tmp_bag = Bag('tmp_bag', tmpbag=True, searchbag=True)
bag_readable = {}
for tiddler in tiddlers:
try:
if bag_readable[tiddler.bag]:
tmp_bag.add_tiddler(store.get(tiddler))
except KeyError:
bag = Bag(tiddler.bag)
bag.skinny = True
bag = store.get(bag)
try:
bag.policy.allows(usersign, 'read')
tmp_bag.add_tiddler(store.get(tiddler))
bag_readable[tiddler.bag] = True
except(ForbiddenError, UserRequiredError):
bag_readable[tiddler.bag] = False
if len(filters):
tiddlers = control.filter_tiddlers_from_bag(tmp_bag, filters)
tmp_bag = Bag('tmp_bag', tmpbag=True)
tmp_bag.add_tiddlers(tiddlers)
return send_tiddlers(environ, start_response, tmp_bag)
示例11: _read_bag_perms
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def _read_bag_perms(environ, tiddler):
"""
Read the permissions for the bag containing
this tiddler.
"""
perms = []
if 'tiddlyweb.usersign' in environ:
store = tiddler.store
if store:
bag = Bag(tiddler.bag)
bag.skinny = True
bag = store.get(bag)
perms = bag.policy.user_perms(
environ['tiddlyweb.usersign'])
return perms
示例12: test_get_bag
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def test_get_bag():
bag = Bag('thing')
bag.desc = 'stuff'
store.put(bag)
if hasattr(bag, 'list_tiddlers'):
retrieved = Bag('thing')
retrieved.skinny = True
retrieved = store.get(retrieved)
assert retrieved.desc == 'stuff'
retrieved = Bag('thing')
retrieved = store.get(retrieved)
assert retrieved.desc == 'stuff'
else:
retrieved = Bag('thing')
retrieved = store.get(retrieved)
assert retrieved.desc == 'stuff'
示例13: post_createrecipe
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def post_createrecipe(environ, start_response):
user = get_user_object(environ)
store = environ['tiddlyweb.store']
recipe_name = environ['tiddlyweb.query'].get('recipe', [''])[0]
bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
publicity = environ['tiddlyweb.query'].get('publicity', [''])[0]
description = environ['tiddlyweb.query'].get('description', [''])[0]
if not bag_name or not recipe_name:
raise HTTP400('missing data')
recipe = Recipe(recipe_name)
bag = Bag(bag_name)
try:
recipe = store.get(recipe)
raise HTTP400('recipe exists')
except NoRecipeError:
pass
try:
bag.skinny = True
bag = store.get(bag)
try:
bag.policy.allows(user, 'read')
except (UserRequiredError, ForbiddenError):
raise HTTP400('bag not readable')
except NoBagError:
bag.policy.owner = user['name']
for constraint in ['read', 'write', 'create', 'delete', 'manage']:
setattr(bag.policy, constraint, [user['name']])
store.put(bag)
if publicity == 'private':
recipe.policy.read = [user['name']]
else:
recipe.policy.read = []
recipe.policy.manage = [user['name']]
recipe.policy.owner = user['name']
recipe.desc = description
recipe.set_recipe([
('system', ''),
(bag.name, ''),
])
store.put(recipe)
raise HTTP303('%s/home' % server_base_url(environ))
示例14: put
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def put(environ, start_response):
"""
Put a bag to the server, meaning the description and
policy of the bag, if policy allows.
"""
bag_name = _determine_bag_name(environ)
bag_name = web.handle_extension(environ, bag_name)
bag = Bag(bag_name)
store = environ['tiddlyweb.store']
length = environ['CONTENT_LENGTH']
usersign = environ['tiddlyweb.usersign']
try:
bag.skinny = True
bag = store.get(bag)
bag.policy.allows(usersign, 'manage')
try:
delattr(bag, 'skinny')
except AttributeError:
pass
except NoBagError:
create_policy_check(environ, 'bag', usersign)
try:
serialize_type = web.get_serialize_type(environ)[0]
serializer = Serializer(serialize_type, environ)
serializer.object = bag
content = environ['wsgi.input'].read(int(length))
serializer.from_string(content.decode('utf-8'))
bag.policy.owner = usersign['name']
_validate_bag(environ, bag)
store.put(bag)
except TypeError:
raise HTTP400('Content-type header required')
except NoSerializationError:
raise HTTP415('Content type not supported: %s' % serialize_type)
start_response("204 No Content",
[('Location', web.bag_url(environ, bag))])
return []
示例15: post_profile
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import skinny [as 别名]
def post_profile(environ, start_response):
usersign = environ['tiddlyweb.usersign']
text = environ['tiddlyweb.query'].get('text', [''])[0]
title = environ['tiddlyweb.query'].get('title', [''])[0]
bag = environ['tiddlyweb.query'].get('bag', [''])[0]
return_url = environ['tiddlyweb.query'].get('return_url', ['/home'])[0]
store = environ['tiddlyweb.store']
tiddler = Tiddler(title, bag)
tiddler.text = text
tiddler.modifier = usersign['name']
bag = Bag(bag)
try:
bag.skinny = True
bag = store.get(bag)
except NoBagError, exc:
raise HTTP404('tiddler %s not found: %s' % (tiddler.title, exc))