當前位置: 首頁>>代碼示例>>Python>>正文


Python PageData.get_by方法代碼示例

本文整理匯總了Python中wikidata.PageData.get_by方法的典型用法代碼示例。如果您正苦於以下問題:Python PageData.get_by方法的具體用法?Python PageData.get_by怎麽用?Python PageData.get_by使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wikidata.PageData的用法示例。


在下文中一共展示了PageData.get_by方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: goto

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:9,代碼來源:wiki16.py

示例2: edit

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:9,代碼來源:wiki15.py

示例3: init

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
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,代碼行數:10,代碼來源:wiki16.py

示例4: _

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:11,代碼來源:wiki16.py

示例5: render

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
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,代碼行數:12,代碼來源:wiki16.py

示例6: render

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
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,代碼行數:12,代碼來源:wiki2.py

示例7: render

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
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,代碼行數:15,代碼來源:wiki11.py

示例8: edit

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:16,代碼來源:wiki16.py

示例9: goto

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:17,代碼來源:wiki4.py

示例10: render

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
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,代碼行數:23,代碼來源:wiki3.py

示例11: edit

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:24,代碼來源:wiki2.py

示例12: goto

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:8,代碼來源:wiki15.py

示例13: edit

# 需要導入模塊: from wikidata import PageData [as 別名]
# 或者: from wikidata.PageData import get_by [as 別名]
    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,代碼行數:8,代碼來源:wiki6.py


注:本文中的wikidata.PageData.get_by方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。