当前位置: 首页>>代码示例>>Python>>正文


Python Bag.desc方法代码示例

本文整理汇总了Python中tiddlyweb.model.bag.Bag.desc方法的典型用法代码示例。如果您正苦于以下问题:Python Bag.desc方法的具体用法?Python Bag.desc怎么用?Python Bag.desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tiddlyweb.model.bag.Bag的用法示例。


在下文中一共展示了Bag.desc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bag_etag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_bag_etag():
    """
    Explicitly test bag_etag method (not used by the core code).
    """
    bag1 = Bag('foo')
    bag1.desc = 'desc'
    bag2 = Bag('foo')
    bag2.desc = 'desc'

    assert bag_etag(environ, bag1) == bag_etag(environ, bag2)
开发者ID:andrey013,项目名称:tiddlyweb,代码行数:12,代码来源:test_web_util.py

示例2: _ensure_bags

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
    def _ensure_bags(self, environ, username):

      # for privacy in ["public", "protected", "private"]:
      for privacy in ["private", "protected"]:

        only_user = ["admin", username]
        if privacy=="public":
          readPerms = []
          writePerms = []
        elif privacy=="protected":
          readPerms = []
          writePerms = only_user
        elif privacy=="private":
          readPerms = only_user
          writePerms = only_user

        bag = Bag(privacy+"-"+username)
        store = environ['tiddlyweb.store']
        try:
            store.get(bag)
            return
        except NoBagError:
            bag.desc = 'tiddlyguv private user bag'
            bag.policy.owner = username
            bag.policy.manage = ["admin", username]
            bag.policy.read = readPerms
            bag.policy.write = writePerms
            bag.policy.create = ["admin", username]
            bag.policy.delete = ["admin", username]
            store.put(bag)
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:32,代码来源:ldap.py

示例3: _create_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def _create_bag(environ):
    """Take the form input and turn it into a bag."""
    query_data = _flatten_form_data(environ['tiddlyweb.query'])
    logging.debug(query_data)
    store = environ['tiddlyweb.store']
    try:
        new_bag_name = query_data['bag_name']

        if _bag_exists(store, new_bag_name):
            raise HTTP409('That bag may not be created.')

        new_bag = Bag(new_bag_name)

        username = environ['tiddlyweb.usersign']['name']
        new_bag.policy.owner = username
        new_bag.policy.manage = [username]
        new_bag.desc = query_data.get('bag_desc', '')

        for policy_type in ('read', 'write', 'create', 'delete'):
            texted = query_data.get(policy_type + '_text', None)
            logging.debug('texted: %s' % texted)
            if texted:
                new_bag.policy.__setattr__(policy_type, [x.lstrip().rstrip() for x in texted.split(',')])
            else:
                set = query_data[policy_type]
                new_bag.policy.__setattr__(policy_type, _policy_form_to_entry(username, set))

        store.put(new_bag)
    except KeyError, exc:
        raise HTTP400('something went wrong processing for: %s' % exc)
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:32,代码来源:mine.py

示例4: create_wiki

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def create_wiki(environ, name, mode='private', username=None, desc='',
        validate=True):
    """
    Create a wiki with the name, name.

    For now a wiki is just a bag a policy.
    """
    store = environ['tiddlyweb.store']
    if username is None:
        username = environ['tiddlyweb.usersign']['name']

    bag = Bag(name)

    # We want this get to fail.
    try:
        store.get(bag)
        return False
    except NoBagError:
        pass

    try:
        bag.policy = WIKI_MODES[mode](username)
    except KeyError:
        bag.policy = WIKI_MODES['private'](username)
    bag.desc = desc
    if validate:
        validate_bag(bag, environ)
    store.put(bag)

    return bag
开发者ID:pads,项目名称:tank,代码行数:32,代码来源:wiki.py

示例5: _bag_list

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
 def _bag_list(self, tiddlers):
     if '/feedbag' in self.environ['selector.matches'][0]:
         representation_link = '%s/feedbag' % (self._server_prefix())
         bag = Bag('feedbag')
         bag.policy.manage = ["NONE"]
         bag.policy.delete = ["NONE"]
         bag.desc = 'Recent Public Stuff'
     else:
         name = self.environ['wsgiorg.routing_args'][1]['bag_name']
         name = urllib.unquote(name)
         name = name.decode('utf-8')
         representation_link = '%s/bags/%s/tiddlers' % (
                 self._server_prefix(), encode_name(name))
         bag = self.environ['tiddlyweb.store'].get(Bag(name))
     representations = self._tiddler_list_header(representation_link)
     user_object = get_user_object(self.environ)
     publicity = ''
     try:
         bag.policy.allows(user_object, 'manage')
         policy = bag.policy
         publicity = determine_publicity(user_object, policy)
     except (UserRequiredError, ForbiddenError):
         policy = None
     try:
         bag.policy.allows(user_object, 'delete')
         delete = True
     except (UserRequiredError, ForbiddenError):
         delete = False
     data = {'title': 'TiddlyHoster Bag %s' % bag.name, 'policy': policy,
             'publicity': publicity, 'delete': delete,
             'bag': bag, 'tiddlers': tiddlers, 'representations': representations}
     del self.environ['tiddlyweb.title']
     return send_template(self.environ, 'baglist.html', data)
开发者ID:ralphbtp,项目名称:tiddlyhoster,代码行数:35,代码来源:serialization.py

示例6: test_validate_bag_desc

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_validate_bag_desc():
    bag = Bag('barney')
    bag.desc = '<script>alert("foo");</script>'

    validate_bag(bag)

    assert bag.desc == '&lt;script&gt;alert("foo");&lt;/script&gt;'
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:9,代码来源:test_validate.py

示例7: test_store_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_store_bag():
    bag_in = Bag('bagone')
    bag_in.desc = 'bag description'
    bag_in.policy.read = ['reader']
    bag_in.policy.write = ['writer']

    store.put(bag_in)

    bag_out = store.get(Bag('bagone'))

    assert bag_out.name == bag_in.name
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:13,代码来源:test_ramstore.py

示例8: test_bag_as_yaml

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_bag_as_yaml(): 
    bag = Bag('test bag')
    tiddlers = [Tiddler('tiddler number ' + str(name)) for name in xrange(2)]
    bag.desc = 'a bag of tiddlers'
    bag.policy.manage = ['NONE']
    bag.policy.delete = ['go away']
    serializer.object = bag
    string = serializer.to_string()
    assert string.startswith(u'desc: a bag of tiddlers\n')
    assert u"\n  delete:\n  - go away\n" in string
    assert u"\n  manage:\n  - NONE\n" in string
开发者ID:psd,项目名称:tiddlyweb.yaml,代码行数:13,代码来源:test_serialize_yaml.py

示例9: test_bag_has_description

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_bag_has_description():
    """
    Confirm a bag can set and use a description.
    """
    bag = Bag('hasbeen', desc='monkey puzzle')

    assert bag.name == 'hasbeen'
    assert bag.desc == 'monkey puzzle'

    bag.desc = 'collapsing sideburns'
    assert bag.desc == 'collapsing sideburns'
开发者ID:24king,项目名称:tiddlyweb,代码行数:13,代码来源:test_bag.py

示例10: test_store_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_store_bag():
    bag = Bag('testone')
    bag.desc = 'testone'
    bag.policy.accept.append('cdent')

    store.put(bag)

    bag2 = Bag('testone')
    bag2 = store.get(bag2)

    assert bag.desc == bag2.desc
    assert bag.name == bag2.name
    assert bag.policy.accept == bag2.policy.accept
开发者ID:cdent,项目名称:tiddlywebredis,代码行数:15,代码来源:test_simple.py

示例11: test_store_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_store_bag():
    bag = Bag('bag1')
    bag.desc = 'bag 1 desc'

    store.put(bag)

    # these should be _description, not description etc
    assert os.path.exists('store/bag1/description')
    assert os.path.exists('store/bag1/policy')

    loaded_bag = Bag('bag1')
    loaded_bag = store.get(loaded_bag)
    assert loaded_bag.desc == bag.desc
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:15,代码来源:test_simple_store.py

示例12: test_delete

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def test_delete():
    bag = Bag("deleteme")
    bag.desc = "delete me please"
    store.put(bag)

    stored_bag = Bag("deleteme")
    stored_bag = store.get(stored_bag)
    assert stored_bag.desc == "delete me please"

    deleted_bag = Bag("deleteme")
    store.delete(deleted_bag)

    py.test.raises(NoBagError, "store.get(deleted_bag)")
    py.test.raises(NoBagError, "store.delete(deleted_bag)")
开发者ID:gravesmedical,项目名称:tiddlyweb,代码行数:16,代码来源:test_store_bag.py

示例13: test_get_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [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'
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.caching,代码行数:19,代码来源:test_bag_handling.py

示例14: ensure_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def ensure_bag(bag_name, store, policy_dict={}, description='', owner=None):
    """
    Ensure that bag with name bag_name exists in store.
    If not, create it with owner, policy and description optionally
    provided. In either case return the bag object.
    """
    bag = Bag(bag_name)
    try:
        bag = store.get(bag)
    except NoBagError:
        bag.desc = description
        if owner:
            bag.policy.owner = owner
            bag.policy.manage = [owner]
        for key in policy_dict:
            bag.policy.__setattr__(key, policy_dict[key])
        store.put(bag)
    return bag
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:20,代码来源:__init__.py

示例15: _check_bag

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import desc [as 别名]
def _check_bag(name, environ, user):
    """
    Get the user's bag. Create if required.
    """
    store = environ['tiddlyweb.store']

    name = '%s-%s' % (user, name)
    name = name.replace('.', '_')
    try:
        bag = Bag(name)
        bag = store.get(bag)
    except NoBagError:
        uni_user = unicode(user)
        policy = Policy(owner=uni_user, manage=[uni_user],
                read=[uni_user], write=[uni_user],
                delete=[uni_user], create=[uni_user])
        bag.policy = policy
        bag.desc = 'Twotes for %s' % uni_user;
        store.put(bag)
    return bag
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:22,代码来源:twoter.py


注:本文中的tiddlyweb.model.bag.Bag.desc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。