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


Python collections.Tiddlers类代码示例

本文整理汇总了Python中tiddlyweb.model.collections.Tiddlers的典型用法代码示例。如果您正苦于以下问题:Python Tiddlers类的具体用法?Python Tiddlers怎么用?Python Tiddlers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: whoosher_search

def whoosher_search(environ, start_response):
    store = environ['tiddlyweb.store']
    filters = environ['tiddlyweb.filters']
    search_query = get_search_query(environ)
    title = 'Search for %s' % search_query
    title = environ['tiddlyweb.query'].get('title', [title])[0]

    try:
        tiddlers = whoosh_search(environ)

        usersign = environ['tiddlyweb.usersign']

        if filters:
            candidate_tiddlers = Tiddlers(title=title)
        else:
            candidate_tiddlers = Tiddlers(title=title, store=store)
        candidate_tiddlers.is_search = True

        for tiddler in readable_tiddlers_by_bag(store, tiddlers, usersign):
            candidate_tiddlers.add(tiddler)

    except StoreMethodNotImplemented:
        raise HTTP400('Search system not implemented')
    except StoreError as exc:
        raise HTTP400('Error while processing search: %s' % exc)

    return send_tiddlers(environ, start_response, tiddlers=candidate_tiddlers)
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.whoosher,代码行数:27,代码来源:whoosher.py

示例2: get_tiddlers

def get_tiddlers(environ, start_response):
    """
    Get a list representation of the tiddlers in a
    bag. The information sent is dependent on the
    serialization chosen.
    """
    store = environ["tiddlyweb.store"]
    filters = environ["tiddlyweb.filters"]
    bag_name = web.get_route_value(environ, "bag_name")
    bag = _get_bag(environ, bag_name)
    title = "Tiddlers From Bag %s" % bag.name
    title = environ["tiddlyweb.query"].get("title", [title])[0]

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

    tiddlers = Tiddlers(title=title)
    if not filters:
        tiddlers.store = store
    tiddlers.bag = bag_name

    # A special bag can raise NoBagError here.
    try:
        for tiddler in store.list_bag_tiddlers(bag):
            tiddlers.add(tiddler)
    except NoBagError, exc:
        raise HTTP404("%s not found, %s" % (bag.name, exc))
开发者ID:FND,项目名称:tiddlyweb,代码行数:28,代码来源:bag.py

示例3: get

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']
    search_query = get_search_query(environ)
    title = 'Search for %s' % search_query
    title = environ['tiddlyweb.query'].get('title', [title])[0]

    try:
        tiddlers = get_tiddlers(environ)

        usersign = environ['tiddlyweb.usersign']

        candidate_tiddlers = Tiddlers(title=title, store=store)
        candidate_tiddlers.is_search = True

        for tiddler in readable_tiddlers_by_bag(store, tiddlers, usersign):
            candidate_tiddlers.add(tiddler)

    except StoreMethodNotImplemented:
        raise HTTP400('Search system not implemented')
    except StoreError, exc:
        raise HTTP400('Error while processing search: %s' % exc)
开发者ID:rdrake98,项目名称:tiddlyweb,代码行数:27,代码来源:search.py

示例4: get_tiddlers

def get_tiddlers(environ, start_response):
    """
    Get a list representation of the tiddlers in a
    bag. The information sent is dependent on the
    serialization chosen.
    """
    store = environ['tiddlyweb.store']
    filters = environ['tiddlyweb.filters']
    bag_name = web.get_route_value(environ, 'bag_name')
    bag = _get_bag(environ, bag_name)
    title = 'Tiddlers From Bag %s' % bag.name
    title = environ['tiddlyweb.query'].get('title', [title])[0]

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

    if filters:
        tiddlers = Tiddlers(title=title)
    else:
        tiddlers = Tiddlers(title=title, store=store)
    for tiddler in store.list_bag_tiddlers(bag):
        tiddlers.add(tiddler)

    tiddlers.link = '%s/tiddlers' % web.bag_url(environ, bag, full=False)

    return send_tiddlers(environ, start_response, tiddlers=tiddlers)
开发者ID:funkyeah,项目名称:tiddlyweb,代码行数:27,代码来源:bag.py

示例5: setup_module

def setup_module(module):
    module.bag = Bag(name='foobag')
    from fixtures import tiddlers as tids
# we need to copy tiddlers otherwise the test below which 
# messes with the contents of tiddlers screws with others tests
    module.tiddlers = copy.deepcopy(tids)
    container = Tiddlers()
    container.add(module.tiddlers[0])
    module.bag.tiddlers = container
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:9,代码来源:test_bag.py

示例6: tiddler_as

 def tiddler_as(self, tiddler):
     """
     Take the single tiddler provided and inject it into
     a TiddlyWiki.
     """
     tiddlers = Tiddlers(title=tiddler.title, bag=tiddler.bag,
             recipe=tiddler.recipe)
     tiddlers.add(tiddler)
     tiddlers.link = tiddler_url(self.environ, tiddler, full=False)
     # Join with '' to return a string not generator.
     return ''.join(self._put_tiddlers_in_tiddlywiki(tiddlers))
开发者ID:tiddlyweb,项目名称:tiddlywebwiki,代码行数:11,代码来源:serialization.py

示例7: test_tiddler_collection

def test_tiddler_collection():
    tiddlers = Tiddlers()
    n = 4
    for title in ['how', 'now', 'cow']:
        n = n - 1
        tiddler = Tiddler(title, 'bag')
        tiddler.modified = n 
        tiddlers.add(tiddler)
    digest = tiddlers.hexdigest()
    modified = tiddlers.modified
    assert ['how', 'now', 'cow'] == list(tiddler.title for tiddler in tiddlers)
    assert modified == '30000000000000'
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:12,代码来源:test_collection_tiddlers.py

示例8: _send_tiddler_revisions

def _send_tiddler_revisions(environ, start_response, tiddler):
    """
    Push the list of tiddler revisions out the network.
    """
    store = environ['tiddlyweb.store']

    title = 'Revisions of Tiddler %s' % tiddler.title
    title = environ['tiddlyweb.query'].get('title', [title])[0]
    container = 'recipes' if tiddler.recipe else 'bags'

    if environ['tiddlyweb.filters']:
        tiddlers = Tiddlers(title=title)
    else:
        tiddlers = Tiddlers(title=title, store=store)

    tiddlers.is_revisions = True
    tiddlers.link = '%s/revisions' % tiddler_url(environ, tiddler,
            container=container, full=False)

    # Set the container on the tiddlers. Since tiddler.recipe
    # defaults to None, we're "safe" here.
    tiddlers.recipe = tiddler.recipe
    tiddlers.bag = tiddler.bag

    try:
        for revision in store.list_tiddler_revisions(tiddler):
            tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
            tmp_tiddler.revision = revision
            tmp_tiddler.recipe = tiddler.recipe
            tiddlers.add(tmp_tiddler)
    except NoTiddlerError, exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
开发者ID:tup,项目名称:tiddlyweb,代码行数:33,代码来源:tiddler.py

示例9: public_stuff

def public_stuff(environ, start_response):
    """
    A collection of the most recent stuff.
    A place where _all_ the content readable
    by the current user can be viewed.
    """
    user = get_user_object(environ)
    store = environ['tiddlyweb.store']
    kept_bags = get_stuff(store, store.list_bags(), user)
    tiddlers = Tiddlers()
    for bag in kept_bags:
        bag = store.get(bag)
        for tiddler in store.list_bag_tiddlers(bag):
            tiddlers.add(tiddler)
    return send_tiddlers(environ, start_response, tiddlers=tiddlers)
开发者ID:ralphbtp,项目名称:tiddlyhoster,代码行数:15,代码来源:__init__.py

示例10: test_content_type

def test_content_type():
    bag = Bag('holder')
    bag = store.get(bag)
    tiddlers = Tiddlers(store=store)
    for tiddler in store.list_bag_tiddlers(bag):
        tiddlers.add(tiddler)

    serializer = Serializer('tiddlywebwiki.serialization', {'tiddlyweb.config': config})
    output = ''.join(serializer.list_tiddlers(tiddlers))

    # we are expecting an img link to the image tiddler
    assert 'server.content-type="image/png"' in output

    # but we want just an html anchor link to the zero
    assert 'server.content-type="application/octet-stream"' in output

    assert 'server.content-type="text/html"' in output
开发者ID:FND,项目名称:tiddlywebwiki,代码行数:17,代码来源:test_serialize_binary.py

示例11: test_collection

def test_collection():
    tiddlers = Tiddlers()
    tiddler = Tiddler('foo', 'null')
    tiddler.text = 'bam'
    tiddler.modifier = 'cdent'
    tiddlers.add(tiddler)
    tiddler = Tiddler('bar', 'null')
    tiddler.text = 'zoom'
    tiddler.modifier = 'cdent'
    tiddlers.add(tiddler)

    output = serializer.list_tiddlers(tiddlers)

    assert '<name>cdent</name>' in output
    assert '<uri>http://0.0.0.0:8080/profiles/cdent</uri>' in output
    assert '<link href="http://pubsubhubbub.appspot.com/" rel="hub">' in output
    assert 'rel="avatar"' in output, output
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:17,代码来源:test_author_handling.py

示例12: send_tiddlers

def send_tiddlers(environ, start_response, tiddlers=None):
    """
    Output the tiddlers contained in the provided
    Tiddlers collection in a Negotiated representation.
    Often, but not always, a wiki.
    """
    last_modified = None
    etag = None
    download = environ['tiddlyweb.query'].get('download', [None])[0]
    filters = environ['tiddlyweb.filters']
    store = environ['tiddlyweb.store']

    if tiddlers.store is None and not filters:
        logging.warn('Incoming tiddlers no store set %s', inspect.stack()[1])

    if filters:
        candidate_tiddlers = Tiddlers(store=store)
        try:
            candidate_tiddlers.title = tiddlers.title
            candidate_tiddlers.link = tiddlers.link
            candidate_tiddlers.is_search = tiddlers.is_search
            candidate_tiddlers.is_revisions = tiddlers.is_revisions
        except AttributeError:
            pass
        try:
            for tiddler in recursive_filter(filters, tiddlers):
                candidate_tiddlers.add(tiddler)
        except FilterError, exc:
            raise HTTP400('malformed filter: %s' % exc)
开发者ID:funkyeah,项目名称:tiddlyweb,代码行数:29,代码来源:sendtiddlers.py

示例13: test_tiddler_racing

def test_tiddler_racing():
    bag = Bag('foo')
    store.put(bag)
    tiddlers = Tiddlers(store=store)

    for title in ['x', 'y', 'z']:
        tiddler = Tiddler(title, 'foo')
        store.put(tiddler)
        tiddlers.add(tiddler)

    tiddler = Tiddler('y', 'foo')
    store.delete(tiddler)

    tids = list(tiddlers)
    assert len(tids) == 2
    assert 'x' in [tiddler.title for tiddler in tids]
    assert 'z' in [tiddler.title for tiddler in tids]
    assert 'y' not in [tiddler.title for tiddler in tids]
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:18,代码来源:test_collection_tiddlers.py

示例14: race_tiddlers

    def race_tiddlers(bag_name, count=2, intitles=['x', 'z'], outtitles=['y']):
        bag = Bag(bag_name)
        store.put(bag)
        tiddlers = Tiddlers(store=store)

        for title in ['x', 'y', 'z']:
            tiddler = Tiddler(title, 'foo')
            store.put(tiddler)
            tiddlers.add(tiddler)

        tiddler = Tiddler('y', 'foo')
        store.delete(tiddler)

        tids = list(tiddlers)
        assert len(tids) == count
        for title in intitles:
            assert title in [tiddler.title for tiddler in tids]
        for title in outtitles:
            assert title not in [tiddler.title for tiddler in tids]
开发者ID:FND,项目名称:tiddlyweb,代码行数:19,代码来源:test_collection_tiddlers.py

示例15: _send_tiddler_revisions

def _send_tiddler_revisions(environ, start_response, tiddler):
    """
    Push the list of tiddler revisions out the network.
    """
    store = environ['tiddlyweb.store']

    title = 'Revisions of Tiddler %s' % tiddler.title
    title = environ['tiddlyweb.query'].get('title', [title])[0]
    tiddlers = Tiddlers(title=title, store=store)
    tiddlers.is_revisions = True
    recipe = tiddler.recipe
    try:
        for revision in store.list_tiddler_revisions(tiddler):
            tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
            tmp_tiddler.revision = revision
            if recipe:
                tmp_tiddler.recipe = recipe
            tiddlers.add(tmp_tiddler)
    except NoTiddlerError, exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
开发者ID:chancejiang,项目名称:tiddlyweb,代码行数:21,代码来源:tiddler.py


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