view MoinMoin/action/ @ 1550:a4f0632414da

using request.cfg.cache more
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 14 Sep 2006 22:49:42 +0200
parents a4efeab7a10f
children fd22bf359a65
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - DeletePage action

    This action allows you to delete a page.

    @copyright: 2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.

from MoinMoin import wikiutil
from MoinMoin.PageEditor import PageEditor
from MoinMoin.action import ActionBase

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):
        # 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
            return _('This page is already deleted or was never created!')
            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. = PageEditor(self.request, self.pagename, do_editor_backup=0)
        success, msg =
        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 '''
        <td class="label"><label>%(comment_label)s</label></td>
        <td class="content">
            <input type="text" name="comment" maxlength="200">
        <td class="buttons">
''' % d

def execute(pagename, request):
    """ Glue code for actions """
    DeletePage(pagename, request).render()