view MoinMoin/action/ @ 876:73cb23fc3378

increased maxlength of some input fields to 200 (port to 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Jun 2006 23:26:17 +0200
parents 8dac4b68072b
children cbbde07e00c4
line wrap: on
line source

# -*- coding: iso-8859-1 -*-
    MoinMoin - RenamePage action

    This action allows you to rename a page.

    @copyright: 2002-2004 Michael Reinsch <>,
                2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.

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

class RenamePage(ActionBase):
    """ Rename 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 = 'rename'
        self.form_trigger_label = _('Rename Page')

    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
            return _('This page is already deleted or was never created!')
            return None

    def do_action(self):
        """ Rename this page to "pagename" """
        _ = self._
        form = self.form
        newpagename = form.get('newpagename', [u''])[0]
        newpagename = self.request.normalizePagename(newpagename)
        comment = form.get('comment', [u''])[0]
        comment = wikiutil.clean_comment(comment) = PageEditor(self.request, self.pagename)
        success, msg =, comment)
        self.newpagename = newpagename # keep there for finish
        return success, msg

    def do_action_finish(self, success):
        if success:
            url = Page(self.request, self.newpagename).url(self.request)

    def get_form_html(self, buttons_html):
        _ = self._
        d = {
            'pagename': self.pagename,
            'newname_label': _("New name"),
            'comment_label': _("Optional reason for the renaming"),
            'buttons_html': buttons_html,
        return '''
        <td class="label"><label>%(newname_label)s</label></td>
        <td class="content">
            <input type="text" name="newpagename" value="%(pagename)s">
        <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 """
    RenamePage(pagename, request).render()