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


Python Tiddlers.is_revisions方法代码示例

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


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

示例1: list_tiddlers

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
    def list_tiddlers(self, tiddlers):
        """
        Turn the contents of a Tiddlers into an Atom Feed.
        """

        authors = set()
        try:
            from tiddlyweb.model.collections import Tiddlers
            config = self.environ['tiddlyweb.config']
            default_filter = config['atom.default_filter']
            filters, _ = parse_for_filters(default_filter, self.environ)
            new_tiddlers = Tiddlers()
            new_tiddlers.is_search = tiddlers.is_search
            new_tiddlers.is_revisions = tiddlers.is_revisions
            new_tiddlers.bag = tiddlers.bag
            new_tiddlers.recipe = tiddlers.recipe
            new_tiddlers.link = tiddlers.link
            for tiddler in recursive_filter(filters, tiddlers):
                new_tiddlers.add(tiddler)
                authors.add(tiddler.modifier)
            new_tiddlers.title = tiddlers.title
            new_tiddlers.is_search = tiddlers.is_search
            new_tiddlers.is_revisions = tiddlers.is_revisions
            tiddlers = new_tiddlers
        except (KeyError, ImportError):
            pass

        author_name = None
        author_link = None
        author_avatar = None
        if len(authors) == 1:
            author_name = authors.pop()
            author_link = self._get_author_link(author_name)
            author_avatar = self._get_author_avatar(author_name)

        hub = self.environ.get('tiddlyweb.config', {}).get('atom.hub', None)

        if tiddlers.link:
            link = tiddlers.link
        else:
            link = self._current_url()
        if not link.startswith('http'):
            link = u'%s%s' % (self._host_url(), link)

        feed = AtomFeed(link=link,
            language=u'en',
            hub=hub,
            author_name=author_name,
            author_link=author_link,
            author_avatar=author_avatar,
            title=tiddlers.title,
            description=tiddlers.title)

        for tiddler in tiddlers:
            self._add_tiddler_to_feed(feed, tiddler)

        # can we avoid sending utf-8 and let the wrapper handle it?
        return feed.writeString('utf-8')
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:60,代码来源:feed.py

示例2: _send_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
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' % web.tiddler_url(environ, tiddler,
            container=container, full=False)

    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:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:32,代码来源:tiddler.py

示例3: send_tiddlers

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
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,代码行数:31,代码来源:sendtiddlers.py

示例4: send_tiddlers

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
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 filters:
        candidate_tiddlers = Tiddlers(store=store)
        try:
            candidate_tiddlers.title = tiddlers.title
            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):
                recipe = tiddler.recipe
                if not tiddler.store:
                    tiddler = store.get(tiddler)
                    if recipe:
                        tiddler.recipe = recipe
                candidate_tiddlers.add(tiddler)
        except FilterError, exc:
            raise HTTP400('malformed filter: %s' % exc)
开发者ID:chancejiang,项目名称:tiddlyweb,代码行数:32,代码来源:sendtiddlers.py

示例5: _filter_tiddlers

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
def _filter_tiddlers(filters, store, tiddlers):
    """
    Filter the tiddlers by filters provided by the enviornment.
    """
    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
        candidate_tiddlers.bag = tiddlers.bag
        candidate_tiddlers.recipe = tiddlers.recipe
    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:tup,项目名称:tiddlyweb,代码行数:21,代码来源:sendtiddlers.py

示例6: _send_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
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,代码行数:23,代码来源:tiddler.py

示例7: _send_tiddler_revisions

# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import is_revisions [as 别名]
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 as exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
    except NoBagError as exc:
        raise HTTP404('tiddler %s not found, bag %s does not exist, %s'
                % (tiddler.title, tiddler.bag, exc))
    except StoreMethodNotImplemented:
        raise HTTP400('no revision support')

    return send_tiddlers(environ, start_response, tiddlers=tiddlers)
开发者ID:24king,项目名称:tiddlyweb,代码行数:42,代码来源:tiddler.py


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