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


Python wikidata.PageData类代码示例

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


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

示例1: goto

    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            log.info('New wiki page: [%s]' % title)
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))
开发者ID:nagareproject,项目名称:examples,代码行数:7,代码来源:wiki16.py

示例2: edit

    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
开发者ID:nagareproject,项目名称:examples,代码行数:7,代码来源:wiki15.py

示例3: init

def init(self, url, *args):
    title = url[1]

    page = PageData.get_by(pagename=title)
    if page is None:
        raise presentation.HTTPNotFound()

    self.goto(title)
开发者ID:nagareproject,项目名称:examples,代码行数:8,代码来源:wiki16.py

示例4: _

    def _(self, user, perm, subject):
        if user.has_permission('wiki.admin'):
            return True

        creator = PageData.get_by(pagename=subject.title).creator
        if user.has_permission(perm) and (perm != 'wiki.editor' or (creator is None) or (creator == user.id)):
            return True

        return common.Denial()
开发者ID:nagareproject,项目名称:examples,代码行数:9,代码来源:wiki16.py

示例5: render

def render(self, h, comp, *args):
    h << h.span('Viewing ') << h.b(self.title) << h.br

    page = PageData.get_by(pagename=self.title)
    if page.creator:
        h << h.i('Created by ', page.creator) << h.br

    h << 'You can return to the ' << h.a('FrontPage', href='page/FrontPage')

    return h.root
开发者ID:nagareproject,项目名称:examples,代码行数:10,代码来源:wiki16.py

示例6: render

def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    with h.div:
        h << h.pre(page.data)

        # This link is added to every page displayed, to be able to edit it
        h << h.a("Edit this page").action(self.edit, comp)

    return h.root
开发者ID:nagareproject,项目名称:examples,代码行数:10,代码来源:wiki2.py

示例7: render

def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)
    html = h.parse_htmlstring(content, fragment=True)[0]

    for node in html.getiterator():
        if node.tag == 'wiki':
            a = h.a(node.text, href='page/' + node.text).action(comp.answer, unicode(node.text))
            node.replace(a)

    return (html, h.a('Edit this page', href='page/' + self.title).action(self.edit, comp))
开发者ID:nagareproject,项目名称:examples,代码行数:13,代码来源:wiki11.py

示例8: edit

    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            log.info('New content for page [%s]: [%s...]' % (self.title, content[:50]))
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content

            # If the creator of the page is not already set, set it with the
            # current user
            if page.creator is None:
                page.creator = security.get_user().id
                log.debug('New creator for page [%s]: [%s]' % (page.pagename, page.creator))
开发者ID:nagareproject,项目名称:examples,代码行数:14,代码来源:wiki16.py

示例9: goto

    def goto(self, title):
        """Navigate to an other page

        In:
          - ``title`` -- title of the new page to display
        """
        # Retrieve the new page data from the database
        page = PageData.get_by(pagename=title)
        if page is None:
            # The new page doesn't exist, create it in database
            PageData(pagename=title, data=u'')

        # Permanently replace, into the component graph, the currently
        # displayed page by the new one
        self.content.becomes(Page(title))
开发者ID:nagareproject,项目名称:examples,代码行数:15,代码来源:wiki4.py

示例10: render

def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    # Translate the content in ``page.data`` to HTML
    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']

    # For each WikiWords found, create a pseudo tag '<wiki>WikiWord</<wiki>'
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)

    # Parse the HTML into a elements tree
    html = h.parse_htmlstring(content, fragment=True)[0]

    # Found the '<wiki>' elements into the tree and transform them into active links
    for node in html.getiterator():
        if node.tag == 'wiki':
            # Clicking on a WikiWord will answer the WikiWord unicode string
            a = h.a(node.text).action(comp.answer, unicode(node.text))
            # Replace the node
            node.replace(a)

    return (html, h.a('Edit this page').action(self.edit, comp))
开发者ID:nagareproject,项目名称:examples,代码行数:21,代码来源:wiki3.py

示例11: edit

    def edit(self, comp):
        """Edit the content of this page:

           1. a page editor is created
           2. the page editor temporary replace the page in the component graph
           3. it will return (and restore the page) with the new content of the
              page

        In:
          - ``comp`` -- this component
        """
        # A ``PageEditor`` object is created for ``self``
        # It temporary replaces the current component (the page displayed)
        content = comp.call(PageEditor(self))

        # ``content`` is the new content for the page
        # or ``None`` if the user canceled the modification
        if content is not None:
            # Retrieve the database object
            page = PageData.get_by(pagename=self.title)
            # Change the content
            page.data = content
开发者ID:nagareproject,项目名称:examples,代码行数:22,代码来源:wiki2.py

示例12: goto

    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))
开发者ID:nagareproject,项目名称:examples,代码行数:6,代码来源:wiki15.py

示例13: edit

    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            page = PageData.get_by(pagename=self.title)
            page.data = content
开发者ID:nagareproject,项目名称:examples,代码行数:6,代码来源:wiki6.py


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