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


Python PageEditor.deletePage方法代码示例

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


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

示例1: nuke_page

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
def nuke_page(request, pagename):
    """ completely delete a page, everything in the pagedir """
    page = PageEditor(request, pagename, do_editor_backup=False)
    page.deletePage()
    # really get rid of everything there:
    fpath = page.getPagePath(check_create=0)
    shutil.rmtree(fpath, True)
开发者ID:steveyen,项目名称:moingo,代码行数:9,代码来源:__init__.py

示例2: execute

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
def execute(pagename, request):
    _ = request.getText
    actname = __name__.split('.')[-1]
    # Create a page editor that does not do edior backups, becuase
    # delete generate "deleted" version, of the page.
    page = PageEditor(request, pagename, do_editor_backup=0)

    # be extra paranoid in dangerous actions
    if actname in request.cfg.excluded_actions \
            or not request.user.may.write(pagename) \
            or not request.user.may.delete(pagename):
        return page.send_page(request,
            msg = _('You are not allowed to delete this page.'))

    # check whether page exists at all
    if not page.exists():
        return page.send_page(request,
            msg = _('This page is already deleted or was never created!'))

    # check whether the user clicked the delete button
    if request.form.has_key('button') and request.form.has_key('ticket'):
        # check whether this is a valid deletion request (make outside
        # attacks harder by requiring two full HTTP transactions)
        if not wikiutil.checkTicket(request.form['ticket'][0]):
            return page.send_page(request,
                msg = _('Please use the interactive user interface to delete pages!'))

        # Delete the page
        page.deletePage(request.form.get('comment', [u''])[0])

        return page.send_page(request,
                msg = _('Page "%s" was successfully deleted!') % (pagename,))

    # send deletion form
    ticket = wikiutil.createTicket()
    querytext = _('Really delete this page?')
    button = _('Delete')
    comment_label = _("Optional reason for the deletion")

    # TODO: this form suck, redesign like RenamePage
    formhtml = '''
<form method="post" action="">
<strong>%(querytext)s</strong>
<input type="hidden" name="action" value="%(actname)s">
<input type="hidden" name="ticket" value="%(ticket)s">
<input type="submit" name="button" value="%(button)s">
<p>
%(comment_label)s<br>
<input type="text" name="comment" size="60" maxlength="80">
</form>''' % {
    'querytext': querytext,
    'actname': actname,
    'ticket': ticket,
    'button': button,
    'comment_label': comment_label,
}

    return page.send_page(request, msg=formhtml)
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:60,代码来源:DeletePage.py

示例3: nuke_page

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
def nuke_page(request, pagename):
    """ completely delete a page, everything in the pagedir """
    attachments = AttachFile._get_files(request, pagename)
    for attachment in attachments:
        AttachFile.remove_attachment(request, pagename, attachment)
    page = PageEditor(request, pagename, do_editor_backup=False)
    page.deletePage()
    # really get rid of everything there:
    fpath = page.getPagePath(check_create=0)
    shutil.rmtree(fpath, True)
开发者ID:happytk,项目名称:moin,代码行数:12,代码来源:__init__.py

示例4: do_deletepage

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def do_deletepage(self, pagename, comment="Deleted by the scripting subsystem."):
        """ Marks a page as deleted (like the DeletePage action).

        @param pagename: page to delete
        @param comment:  the related comment (optional)
        """
        _ = self.request.getText
        page = PageEditor(self.request, pagename, do_editor_backup=0)
        if not page.exists():
            raise RuntimeScriptException(_("The page %s does not exist.") % pagename)

        page.deletePage(comment)
开发者ID:imosts,项目名称:flume,代码行数:14,代码来源:packages.py

示例5: xmlrpc_mergeDiff

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
        """
        Merges a diff sent by the remote machine and returns the number of the new revision.
        Additionally, this method tags the new revision.

        @param pagename: The pagename that is currently dealt with.
        @param diff: The diff that can be applied to the version specified by delta_remote_rev.
            If it is None, the page is deleted.
        @param local_rev: The revno of the page on the other wiki system, used for the tag.
        @param delta_remote_rev: The revno that the diff is taken against.
        @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
        @param interwiki_name: Used to build the interwiki tag.
        @param normalised_name: The normalised pagename that is common to both wikis.

        @return: Returns the current revision number after the merge was done. Or one of the following errors:
            * "SUCCESS" - the page could be merged and tagged successfully.
            * "NOT_EXIST" - item does not exist and there was not any content supplied.
            * "LASTREV_INVALID" - the page was changed and the revision got invalid
            * "INTERNAL_ERROR" - there was an internal error
            * "NOT_ALLOWED" - you are not allowed to do the merge operation on the page
        """
        from MoinMoin.util.bdiff import decompress, patch
        from MoinMoin.wikisync import TagStore, BOTH
        from MoinMoin.packages import unpackLine
        LASTREV_INVALID = xmlrpclib.Fault("LASTREV_INVALID", "The page was changed")

        pagename = self._instr(pagename)

        comment = u"Remote Merge - %r" % unpackLine(interwiki_name)[-1]

        # User may read page?
        if not self.request.user.may.read(pagename) or not self.request.user.may.write(pagename):
            return xmlrpclib.Fault("NOT_ALLOWED", "You are not allowed to write to this page.")

        # XXX add locking here!

        # current version of the page
        currentpage = PageEditor(self.request, pagename, do_editor_backup=0)

        if last_remote_rev is not None and currentpage.get_real_rev() != last_remote_rev:
            return LASTREV_INVALID

        if not currentpage.exists() and diff is None:
            return xmlrpclib.Fault("NOT_EXIST", "The page does not exist and no diff was supplied.")

        if diff is None: # delete the page
            try:
                currentpage.deletePage(comment)
            except PageEditor.AccessDenied, (msg, ):
                return xmlrpclib.Fault("NOT_ALLOWED", msg)
            return currentpage.get_real_rev()
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:53,代码来源:__init__.py

示例6: do_deletepage

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def do_deletepage(self, pagename, comment="Deleted by the scripting subsystem."):
        """ Marks a page as deleted (like the DeletePage action).

        @param pagename: page to delete
        @param comment:  the related comment (optional)
        """
        if self.request.user.may.write(pagename):
            _ = self.request.getText
            page = PageEditor(self.request, pagename, do_editor_backup=0)
            if not page.exists():
                raise RuntimeScriptException(_("The page %s does not exist.") % pagename)
            page.deletePage(comment)
        else:
            self.msg += u"action delete page: not enough rights - nothing done \n"
开发者ID:steveyen,项目名称:moingo,代码行数:16,代码来源:packages.py

示例7: rollback_local_change

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
 def rollback_local_change(): # YYY direct local access
     comment = u"Wikisync rollback"
     rev = new_local_rev - 1
     revstr = '%08d' % rev
     oldpg = Page(self.request, sp.local_name, rev=rev)
     pg = PageEditor(self.request, sp.local_name)
     if not oldpg.exists():
         pg.deletePage(comment)
     else:
         try:
             savemsg = pg.saveText(oldpg.get_raw_body(), 0, comment=comment, extra=revstr, action="SAVE/REVERT")
         except PageEditor.Unchanged:
             pass
     return sp.local_name
开发者ID:steveyen,项目名称:moingo,代码行数:16,代码来源:SyncPages.py

示例8: _remove_user_from_team

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
def _remove_user_from_team(u, team, cfg):
    acl_request = u._request
    acl_request.user = user.User(acl_request, None, cfg.openidrp_acl_admin)
    pe = PageEditor(acl_request, team + cfg.openidrp_acl_page_postfix)
    acl_text = pe.get_raw_body()
    logging.log(logging.INFO, "ACL Page content: " + acl_text)
    # does ACL want uid, name, username, auth_username?
    p = re.compile(ur"^ \* %s" % u.name, re.MULTILINE)
    if p.search(acl_text):
        logging.log(logging.INFO, "found user %s in acl, removing..." % u.name)
        acl_text = acl_text.replace(" * %s\n" % u.name, "")
        try:
            pe.saveText(acl_text, 0)
        except PageEditor.EmptyPage:
            pe.deletePage()
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:17,代码来源:openidrp_teams.py

示例9: delete

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
def delete(request, pagename, comment = None):
    _ = request.getText
    
    # check ACLs
    if not request.user.may.delete(pagename):
        return xmlrpclib.Fault(1, _("You are not allowed to delete this page"))
    
    # Deletes pages

    page = PageEditor(request, pagename, do_editor_backup=0)
    if not page.exists():
        return xmlrpclib.Fault(1, _('No such page %s' % pagename))

    page.deletePage(comment)

    return True
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:18,代码来源:DeletePage.py

示例10: DeletePage

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
class DeletePage(ActionBase):
    """ Delete page action

    Note: the action name is the class name
    """
    def __init__(self, pagename, request):
        ActionBase.__init__(self, pagename, request)
        self.use_ticket = True
        _ = self._
        self.form_trigger = 'delete'
        self.form_trigger_label = _('Delete')

    def is_allowed(self):
        may = self.request.user.may
        return may.write(self.pagename) and may.delete(self.pagename)
    
    def check_condition(self):
        _ = self._
        if not self.page.exists():
            return _('This page is already deleted or was never created!')
        else:
            return None
        
    def do_action(self):
        """ Delete pagename """
        form = self.form
        comment = form.get('comment', [u''])[0]
        comment = wikiutil.clean_comment(comment)
        
        # Create a page editor that does not do editor backups, because
        # delete generates a "deleted" version of the page.
        self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
        success, msg = self.page.deletePage(comment)
        return success, msg

    def get_form_html(self, buttons_html):
        _ = self._
        d = {
            'pagename': self.pagename,
            'comment_label': _("Optional reason for the deletion"),
            'buttons_html': buttons_html,
            'querytext': _('Really delete this page?'),
        }
        return '''
<strong>%(querytext)s</strong>
<table>
    <tr>
        <td class="label"><label>%(comment_label)s</label></td>
        <td class="content">
            <input type="text" name="comment" maxlength="200">
        </td>
    </tr>
    <tr>
        <td></td>
        <td class="buttons">
            %(buttons_html)s
        </td>
    </tr>
</table>
''' % d
开发者ID:imosts,项目名称:flume,代码行数:62,代码来源:DeletePage.py

示例11: testSaveAbort

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def testSaveAbort(self):
        """Test if saveText() is interrupted if PagePreSave event handler returns Abort"""

        def handler(event):
            from MoinMoin.events import Abort
            return Abort("This is just a test")

        pagename = u'AutoCreatedMoinMoinTemporaryTestPageFortestSave'
        testtext = u'ThisIsSomeStupidTestPageText!'

        self.request.cfg.event_handlers = [handler]

        page = Page(self.request, pagename)
        if page.exists():
            deleter = PageEditor(self.request, pagename)
            deleter.deletePage()

        editor = PageEditor(self.request, pagename)
        editor.saveText(testtext, 0)

        print "PageEditor can't save a page if Abort is returned from PreSave event handlers"
        page = Page(self.request, pagename)
        assert page.body != testtext
开发者ID:Opngate,项目名称:moinmoin,代码行数:25,代码来源:test_PageEditor.py

示例12: testCreateDictAndDeleteDictPage

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def testCreateDictAndDeleteDictPage(self):
        """
        simple test if it is possible to delete a Dict page after creation
        """
        become_trusted(self.request)
        pagename = u'SomeDict'
        page = PageEditor(self.request, pagename, do_editor_backup=0)
        body = u"This is an example text"
        page.saveText(body, 0)

        success_i, result = page.deletePage()

        expected = u'Page "SomeDict" was successfully deleted!'

        assert result == expected
开发者ID:Opngate,项目名称:moinmoin,代码行数:17,代码来源:test_PageEditor.py

示例13: read_events

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
    def read_events(self, url):

        """
        Read events from the given events RSS feed, specified by 'url', creating
        new Wiki pages where appropriate.
        """

        request = self.request
        request.user.may = IAmRoot()
        category_pagenames = self.options.categories.split()

        # Locate the template for events.

        template_page = PageEditor(request, self.options.template)

        if not template_page.exists():
            print "Template %r cannot be found. Not importing any events!" % self.options.template
            return

        # Process the feed.

        feed = urllib.urlopen(url)

        try:
            nodes = xml.dom.pulldom.parse(feed)
            event_details = {}

            in_item = 0

            # Read the nodes from the feed.

            for node_type, value in nodes:
                if node_type == xml.dom.pulldom.START_ELEMENT:
                    if value.nodeName == "item":
                        in_item = 1

                    # Get the value of the important fields.

                    elif in_item and value.nodeName in self.FIELDS:
                        nodes.expandNode(value)
                        event_details[value.nodeName] = self.text(value)

                    # Where all fields have been read, make a new page.

                    if reduce(lambda x, y: x and event_details.has_key(y), self.FIELDS, 1):

                        # Define the page.

                        title = event_details["title"]

                        # Use any parent page information.

                        full_title = EventAggregatorSupport.getFullPageName(self.options.parent, title)

                        # Find the start and end dates.

                        dates = EventAggregatorSupport.getDateStrings(title)

                        # Require one or two dates.

                        if dates and 1 <= len(dates) <= 2:

                            # Deduce the end date.

                            if len(dates) == 2:
                                start_date, end_date = dates
                            elif len(dates) == 1:
                                start_date = end_date = dates[0]

                            # Load the new page and replace the event details in the body.

                            new_page = PageEditor(request, full_title,
                                uid_override=self.options.author)

                            # Delete the page if requested.

                            if new_page.exists() and self.options.delete:

                                try:
                                    new_page.deletePage()
                                except new_page.AccessDenied:
                                    print "Page %r has not been deleted." % full_title

                            # Complete the new page.

                            elif not new_page.exists() or self.options.overwrite:
                                event_details["summary"] = title
                                event_details["start"] = start_date
                                event_details["end"] = end_date

                                try:
                                    EventAggregatorSupport.fillEventPageFromTemplate(
                                        template_page, new_page, event_details,
                                        category_pagenames)

                                except new_page.Unchanged:
                                    print "Page %r is not changed." % full_title

                            else:
                                print "Not overwriting page %r." % full_title
#.........这里部分代码省略.........
开发者ID:bfmags,项目名称:foss_events,代码行数:103,代码来源:eventfeed.py

示例14: DeletePage

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
class DeletePage(ActionBase):
    """ Delete page action

    Note: the action name is the class name
    """
    def __init__(self, pagename, request):
        ActionBase.__init__(self, pagename, request)
        self.use_ticket = True
        _ = self._
        self.form_trigger = 'delete'
        self.form_trigger_label = _('Delete')
        filterfn = re.compile(ur"^%s/.*$" % re.escape(pagename), re.U).match
        subpagenames = request.rootpage.getPageList(user='', exists=1, filter=filterfn)
        self.subpages = [pagename for pagename in subpagenames if self.request.user.may.delete(pagename)]

    def is_allowed(self):
        # this is not strictly necessary because the underlying storage code checks
        # as well
        may = self.request.user.may
        return may.write(self.pagename) and may.delete(self.pagename)

    def check_condition(self):
        _ = self._
        if not self.page.exists():
            return _('This page is already deleted or was never created!')
        else:
            return None

    def do_action(self):
        """ Delete pagename """
        form = self.form
        comment = form.get('comment', u'')
        comment = wikiutil.clean_input(comment)

        # Create a page editor that does not do editor backups, because
        # delete generates a "deleted" version of the page.
        self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
        success, msgs = self.page.deletePage(comment)

        delete_subpages = 0
        try:
            delete_subpages = int(form['delete_subpages'])
        except:
            pass

        if delete_subpages and self.subpages:
            for name in self.subpages:
                self.page = PageEditor(self.request, name, do_editor_backup=0)
                success_i, msg = self.page.deletePage(comment)
                msgs = "%s %s" % (msgs, msg)

        return success, msgs

    def get_form_html(self, buttons_html):
        _ = self._

        if self.subpages:
            subpages = ' '.join(self.subpages)

            d = {
                'subpage': subpages,
                'subpages_checked': ('', 'checked')[self.request.args.get('subpages_checked', '0') == '1'],
                'subpage_label': _('Delete all /subpages too?'),
                'comment_label': _("Optional reason for the deletion"),
                'buttons_html': buttons_html,
                'querytext': _('Really delete this page?'),
                }

            return '''
<strong>%(querytext)s</strong>
<br>
<br>
<table>
<tr>
<dd>
%(subpage_label)s<input type="checkbox" name="delete_subpages" value="1" %(subpages_checked)s> </dd>
<dd><class="label"><subpage> %(subpage)s</subpage></dd>
</tr>
</table>
<table>
    <tr>
        <td class="label"><label>%(comment_label)s</label></td>
        <td class="content">
            <input type="text" name="comment" size="80" maxlength="200">
        </td>
    </tr>
    <tr>
        <td></td>
        <td class="buttons">
            %(buttons_html)s
        </td>
    </tr>
</table>
''' % d

        else:
            d = {
                'pagename': self.pagename,
                'comment_label': _("Optional reason for the deletion"),
                'buttons_html': buttons_html,
#.........这里部分代码省略.........
开发者ID:IvanLogvinov,项目名称:soar,代码行数:103,代码来源:DeletePage.py

示例15: delete_page

# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import deletePage [as 别名]
 def delete_page(self, pagename, comment):
     page = PageEditor(self.request, pagename)
     try:
         page.deletePage(comment)
     except PageEditor.AccessDenied, (msg, ):
         return msg
开发者ID:steveyen,项目名称:moingo,代码行数:8,代码来源:wikisync.py


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