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


Python Bag.add_tiddlers方法代码示例

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


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

示例1: test_get_revision

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def test_get_revision():
    """
    Test we are able to retrieve a particular revision.
    """

    bagone = Bag('bagone')
    bagone.add_tiddlers(tiddlers)

    store.put(bagone)
    store.put(bagone)
    tiddler = Tiddler('RevisionTiddler')
    tiddler.text='how now 1'
    tiddler.bag = 'bagone'
    store.put(tiddler)
    tiddler.text = 'how now 2'
    store.put(tiddler)
    tiddler.text = 'how now 3'
    store.put(tiddler)

    tiddler = Tiddler(title='RevisionTiddler', bag='bagone')
    tiddler = store.get(tiddler)

    assert tiddler.text == 'how now 3'
    assert tiddler.revision == 3

    tiddler = Tiddler(title='RevisionTiddler', bag='bagone')
    tiddler.revision = 2
    tiddler = store.get(tiddler)

    assert tiddler.text == 'how now 2'
    assert tiddler.revision == 2

    revisions = store.list_tiddler_revisions(tiddler)
    assert len(revisions) == 3
    assert revisions[0] == 3
开发者ID:djswagerman,项目名称:tiddlyweb,代码行数:37,代码来源:test_store_tiddler.py

示例2: tagged_tiddlers

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def tagged_tiddlers(environ, start_response):
    store = environ['tiddlyweb.store']
    bag_name = unicode(urllib.unquote(environ['wsgiorg.routing_args'][1]['bag_name']), 'utf-8')
    tag_name = unicode(urllib.unquote(environ['wsgiorg.routing_args'][1]['tag_name']), 'utf-8')
    bag = store.get(Bag(bag_name))
    tmp_bag = Bag('tmpbag', tmpbag=True)
    tmp_bag.add_tiddlers(control.filter_tiddlers_from_bag(bag, 'select=tag:%s' % tag_name))

    return send_tiddlers(environ, start_response, tmp_bag)
开发者ID:FND,项目名称:tiddlyweb-plugins-1,代码行数:11,代码来源:tagview.py

示例3: get_tiddlers_bag_for_recipe

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
    def get_tiddlers_bag_for_recipe(self,recipe_name):
        store = self.environ['tiddlyweb.store'] 
        recipe = store.get(Recipe(recipe_name))
        list_tiddlers = control.get_tiddlers_from_recipe(recipe)
    
        tiddlers = []

        tempbag = Bag("tempbag",tmpbag=True)
    
        tempbag.add_tiddlers(list_tiddlers)
        return tempbag
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:13,代码来源:nojs.py

示例4: get

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

示例5: user_page

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def user_page(environ, start_response): 
    print(environ)
    name = environ['wsgiorg.routing_args'][1].get('name', 'default')
    recipe = Recipe('tmp')
    recipe.set_recipe([
        [name, '']
   	     ]) 
    # establish the store on the recipe so that get_tiddlers_from_recipe
    # will load the bags and their tiddler lists from the store
    recipe.store = environ['tiddlyweb.store']
    tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
    bag = Bag('tmp', tmpbag=True)
    bag.add_tiddlers(tiddlers)
    return send_tiddlers(environ, start_response, bag)
开发者ID:simonmcmanus,项目名称:goodtube,代码行数:16,代码来源:users.py

示例6: get_tiddlers

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def get_tiddlers(environ, start_response):
    """
    Get the list of tiddlers produced by this
    recipe.
    """
    filter_string = web.filter_query_string(environ)
    usersign = environ['tiddlyweb.usersign']
    store = environ['tiddlyweb.store']
    recipe = _determine_recipe(environ)

    recipe.policy.allows(usersign, 'read')

    # get the tiddlers from the recipe and uniquify them
    try:
        tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
        tmp_bag = Bag('tmp_bag1', tmpbag=True)
        tmp_bag.add_tiddlers(tiddlers)
    except NoBagError, exc:
        raise HTTP404('recipe %s lists an unknown bag: %s' % (recipe.name, exc))
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:21,代码来源:recipe.py

示例7: profile_listing_tiddlers

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def profile_listing_tiddlers():
    store = Store('text', environ=environ)
    environ['tiddlyweb.store'] = store

    bag = Bag('profiler')
    bag.skinny = True
    store.get(bag)

    print 'filter', time()
    filter_string = 'select=tag:100'
    filters, leftovers = parse_for_filters(filter_string, environ)
    tiddlers = control.filter_tiddlers_from_bag(bag, filters)

    print 'tmp bag', time()
    tmp_bag = Bag('tmp_bag', tmpbag=True)
    tmp_bag.add_tiddlers(tiddlers)

    print 'output', time()
    print [tiddler.title for tiddler in control.get_tiddlers_from_bag(tmp_bag)]
开发者ID:chancejiang,项目名称:tiddlyweb,代码行数:21,代码来源:list_tiddlers.py

示例8: pass_through_external_serializer

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
    def pass_through_external_serializer(self, name, tiddlers):
        """
        The specified template has not been found, so assume it
        is a different serializer that has ended up here due to
        content-type confusion, or has been specified as a sub-
        template within another template.

        Passes the serializer name into the Serializer base class
        so that it is rendered by the correct serializer and 
        returns the output.
        """
        serializer_module = self.environ['tiddlyweb.config']['serializers'].get(self.environ['tiddlyweb.config']['extension_types'].get(name))[0]
        serializer = Serializer(serializer_module, self.environ)
        
        if (type(tiddlers) != Tiddler):
            bag = Bag('tmpBag', tmpbag=True)
            bag.add_tiddlers(tiddlers)
        try:
            serializer.object = tiddlers
            return serializer.to_string()
        except AttributeError:
            return serializer.list_tiddlers(bag)
开发者ID:bengillies,项目名称:TiddlyWeb-Plugins,代码行数:24,代码来源:serialization.py

示例9: test_simple_put

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def test_simple_put():
    """
    put a tiddler to disk and make sure it is there.
    """
    bagone = Bag('bagone')
    bagone.add_tiddlers(tiddlers)

    store.put(bagone)
    tiddler = bagone.list_tiddlers()[0]
    print tiddler.revision
    tiddler.tags = ['tagone', 'tagtwo', 'tag five']
    tiddler.modified = '200803030303'
    store.put(tiddler)

    if type(store.storage) != Texter:
        py.test.skip('skipping this test for non-text store')
    
    assert os.path.exists(expected_stored_filename)

    f = file(expected_stored_filename)
    text = f.read()

    assert text == expected_stored_text
开发者ID:djswagerman,项目名称:tiddlyweb,代码行数:25,代码来源:test_store_tiddler.py

示例10: tiddlers

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def tiddlers(context, *args):
    base = context.var_get_text("$BASE_URL")
    path = ""
    
    if not context.environ:
        return ""
    else:
      environ = context.environ
    
    store = get_store(config)
    
    tid = context.tiddler
    if tid.recipe:
        tids = control.get_tiddlers_from_recipe(store.get(Recipe(tid.recipe)))
    elif tid.bag:
        bag = store.get(Bag(tid.bag))
        tids = list(bag.list_tiddlers())
    else:
        return u""
    
    tiddlerTemplate = args[0].text
    templateText = ""  
    for tid in tids:
        tid = store.get(tid)
        if tid.title == tiddlerTemplate:
            templateText = tid.text
    p = parseParams(args)
    if "filter" in p:
        filterBag = Bag("filter",tmpbag=True)
        filterBag.add_tiddlers(tids)
        filtered_tiddlers = filter_tiddlers(filterBag,p["filter"])
        output = u""
        for filtered_tiddler in filtered_tiddlers:
            output += u"%s"%wikitext_to_wikklyhtml(base,path, templateText, environ,tiddler=filtered_tiddler)
        return "<html>%s</html>"%output
    else:
        return u""
开发者ID:jdlrobson,项目名称:tiddlyweb-plugins,代码行数:39,代码来源:__init__.py

示例11: profile_listing_tiddlers

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
def profile_listing_tiddlers():
    store = Store('text', environ=environ)

    bag = Bag('profiler')
    store.get(bag)

    print 'filter', time()
    #filter_string = '[sort[modified]]'
    filter_string = ''
    tiddlers = control.filter_tiddlers_from_bag(bag, filter_string)

    print 'tmp bag', time()
    tmp_bag = Bag('tmp_bag', tmpbag=True)
    tmp_bag.add_tiddlers(tiddlers)

    #print 'output', time()
    #print ['.' for tiddler in control.get_tiddlers_from_bag(tmp_bag)]

    print 'serializer', time()
    serializer = Serializer('wiki', environ)
    print 'wikify', time()
    output = serializer.list_tiddlers(tmp_bag)

    print 'done', time()
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:26,代码来源:list_tiddlers.py

示例12: _determine_bag_name

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
    """
    filters = environ["tiddlyweb.filters"]

    bag_name = _determine_bag_name(environ)
    bag = _get_bag(environ, bag_name)

    usersign = environ["tiddlyweb.usersign"]
    # will raise exception if there are problems
    bag.policy.allows(usersign, "read")

    try:
        tiddlers = control.filter_tiddlers_from_bag(bag, filters)
    except FilterError, exc:
        raise HTTP400("malformed filter: %s" % exc)
    tmp_bag = Bag("tmp_bag", tmpbag=True)
    tmp_bag.add_tiddlers(tiddlers)

    return send_tiddlers(environ, start_response, tmp_bag)


def import_wiki(environ, start_response):
    """
    Accept a tiddlywiki as POST and using it as the source
    parse it for tiddlers to be stored in the named bag.
    """
    bag_name = _determine_bag_name(environ)
    bag = _get_bag(environ, bag_name, True)
    length = environ["CONTENT_LENGTH"]
    content = environ["wsgi.input"].read(int(length))

    bag.policy.allows(environ["tiddlyweb.usersign"], "create")
开发者ID:ingydotnet,项目名称:tiddlyweb,代码行数:33,代码来源:bag.py

示例13: apply_sort

# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import add_tiddlers [as 别名]
 def apply_sort(self):
   bag = Bag("tmp",tmpbag=True)
   bag.add_tiddlers(self.final_tiddlers)
   tiddlers = control.filter_tiddlers_from_bag(bag,'sort=%s'%self.arg2) 
   self.final_tiddlers = list(tiddlers)
开发者ID:jdlrobson,项目名称:tiddlyweb-plugins,代码行数:7,代码来源:filterer.py


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