Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.action.revert.revert Class Reference
Inheritance diagram for MoinMoin.action.revert.revert:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.action.revert.revert:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def is_allowed
def check_condition
def do_action
def get_form_html
def is_excluded
def ticket_ok
def make_buttons
def make_form
def render_msg
def render_success
def render_cancel
def render
def do_action_finish

Public Attributes

 use_ticket
 form_trigger
 form_trigger_label
 method
 request
 form
 cfg
 pagename
 actionname
 user_html
 form_cancel
 form_cancel_label
 page
 error
 enctype

Detailed Description

revert page action

Note: the action name is the class name

Definition at line 16 of file revert.py.


Constructor & Destructor Documentation

def MoinMoin.action.revert.revert.__init__ (   self,
  pagename,
  request 
)

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 21 of file revert.py.

00021 
00022     def __init__(self, pagename, request):
00023         ActionBase.__init__(self, pagename, request)
00024         self.use_ticket = True
00025         _ = self._
00026         self.form_trigger = 'revert'
00027         self.form_trigger_label = _('Revert')
00028         self.method = 'POST'


Member Function Documentation

checks valid page and rev 

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 37 of file revert.py.

00037 
00038     def check_condition(self):
00039         """ checks valid page and rev """
00040         _ = self._
00041         if not self.request.rev or Page(self.request, self.pagename).current_rev() == self.request.rev:
00042             # same string as in PageEditor...
00043             note = _('You were viewing the current revision of this page when you called the revert action. '
00044                      'If you want to revert to an older revision, first view that older revision and '
00045                      'then call revert to this (older) revision again.')
00046             return note
00047         else:
00048             return None

revert pagename 

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 49 of file revert.py.

00049 
00050     def do_action(self):
00051         """ revert pagename """
00052         form = self.form
00053         comment = form.get('comment', u'')
00054         comment = wikiutil.clean_input(comment)
00055 
00056         if self.request.method != 'POST':
00057             return False, u''
00058 
00059         rev = self.request.rev
00060         pg = PageEditor(self.request, self.pagename)
00061 
00062         try:
00063             msg = pg.revertPage(rev, comment)
00064             # make it show the current version...
00065             self.request.rev = None
00066         except PageEditor.RevertError, error:
00067             msg = unicode(error)
00068         except PageEditor.Unchanged, error:
00069             msg = unicode(error)
00070 
00071         return True, msg

def MoinMoin.action.ActionBase.do_action_finish (   self,
  success 
) [inherited]
Override this to handle success or failure (with error in self.error) of your action.

Reimplemented in MoinMoin.action.CopyPage.CopyPage, MoinMoin.action.Load.Load, and MoinMoin.action.RenamePage.RenamePage.

Definition at line 222 of file __init__.py.

00222 
00223     def do_action_finish(self, success):
00224         """ Override this to handle success or failure (with error in self.error) of your action.
00225         """
00226         if success:
00227             self.render_success(self.error, "info")
00228         else:
00229             self.render_msg(self.make_form(), "dialog") # display the form again
00230 
00231 
00232 # Builtin Actions ------------------------------------------------------------

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.revert.revert.get_form_html (   self,
  buttons_html 
)
creates the form 

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 72 of file revert.py.

00072 
00073     def get_form_html(self, buttons_html):
00074         """ creates the form """
00075         _ = self._
00076 
00077         d = {
00078             'pagename': self.pagename,
00079             'comment_label': _("Optional reason for reverting this page"),
00080             'buttons_html': buttons_html,
00081             'querytext': _('Really revert this page?'),
00082             'rev': self.request.rev
00083             }
00084 
00085         return '''
00086 <strong>%(querytext)s</strong>
00087 <table>
00088     <tr>
00089         <td class="label"><label>%(comment_label)s</label></td>
00090         <td class="content">
00091             <input type="text" name="comment" size="80" maxlength="200">
00092             <input type="hidden" name="rev" value="%(rev)d">
00093         </td>
00094     </tr>
00095     <tr>
00096         <td></td>
00097         <td class="buttons">
00098             %(buttons_html)s
00099         </td>
00100     </tr>
00101 </table>
00102 ''' % d
00103 
00104 

Return True if action is allowed (by ACL), or
return a tuple (allowed, message) to show a
message other than the default.

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 29 of file revert.py.

00029 
00030     def is_allowed(self):
00031         # this is not strictly necessary because the underlying storage code checks
00032         # as well
00033         _ = self._
00034         may = self.request.user.may
00035         allowed = may.write(self.pagename) and may.revert(self.pagename)
00036         return allowed, _('You are not allowed to revert this page!')

def MoinMoin.action.ActionBase.is_excluded (   self) [inherited]
Return True if action is excluded 

Definition at line 67 of file __init__.py.

00067 
00068     def is_excluded(self):
00069         """ Return True if action is excluded """
00070         return self.actionname in self.cfg.actions_excluded

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.make_buttons (   self) [inherited]
return a list of form buttons for the action form 

Definition at line 109 of file __init__.py.

00109 
00110     def make_buttons(self):
00111         """ return a list of form buttons for the action form """
00112         return [
00113             (self.form_trigger, self.form_trigger_label),
00114             (self.form_cancel, self.form_cancel_label),
00115         ]

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.make_form (   self) [inherited]
Make some form html for later display.

The form might contain an error that happened when trying to do the action.

Definition at line 116 of file __init__.py.

00116 
00117     def make_form(self):
00118         """ Make some form html for later display.
00119 
00120         The form might contain an error that happened when trying to do the action.
00121         """
00122         from MoinMoin.widget.dialog import Dialog
00123         _ = self._
00124 
00125         if self.error:
00126             error_html = u'<p class="error">%s</p>\n' % self.error
00127         else:
00128             error_html = ''
00129 
00130         buttons = self.make_buttons()
00131         buttons_html = []
00132         for button in buttons:
00133             buttons_html.append('<input type="submit" name="%s" value="%s">' % button)
00134         buttons_html = "".join(buttons_html)
00135 
00136         if self.use_ticket:
00137             ticket_html = '<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(self.request)
00138         else:
00139             ticket_html = ''
00140 
00141         d = {
00142             'method': self.method,
00143             'url': self.request.href(self.pagename),
00144             'enctype': self.enctype,
00145             'error_html': error_html,
00146             'actionname': self.actionname,
00147             'ticket_html': ticket_html,
00148             'user_html': self.get_form_html(buttons_html),
00149         }
00150 
00151         form_html = '''
00152 %(error_html)s
00153 <form action="%(url)s" method="%(method)s" enctype="%(enctype)s">
00154 <div>
00155 <input type="hidden" name="action" value="%(actionname)s">
00156 %(ticket_html)s
00157 %(user_html)s
00158 </div>
00159 </form>''' % d
00160 
00161         return Dialog(self.request, content=form_html)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.render (   self) [inherited]
Render action - this is the main function called by action's
    execute() function.

    We usually render a form here, check for posted forms, etc.

Definition at line 176 of file __init__.py.

00176 
00177     def render(self):
00178         """ Render action - this is the main function called by action's
00179             execute() function.
00180 
00181             We usually render a form here, check for posted forms, etc.
00182         """
00183         _ = self._
00184         form = self.form
00185 
00186         if self.form_cancel in form:
00187             self.render_cancel()
00188             return
00189 
00190         # Validate allowance, user rights and other conditions.
00191         error = None
00192         if self.is_excluded():
00193             error = _('Action %(actionname)s is excluded in this wiki!') % {'actionname': self.actionname }
00194         else:
00195             allowed = self.is_allowed()
00196             if isinstance(allowed, tuple):
00197                 allowed, msg = allowed
00198             else:
00199                 msg = _('You are not allowed to use action %(actionname)s on this page!') % {'actionname': self.actionname }
00200             if not allowed:
00201                 error = msg
00202         if error is None:
00203             error = self.check_condition()
00204         if error:
00205             self.render_msg(error, "error")
00206         elif self.form_trigger in form: # user hit the trigger button
00207             if self.ticket_ok():
00208                 success, self.error = self.do_action()
00209             else:
00210                 success = False
00211                 self.error = _('Please use the interactive user interface to use action %(actionname)s!') % {'actionname': self.actionname }
00212             self.do_action_finish(success)
00213         else:
00214             # Return a new form
00215             self.render_msg(self.make_form(), "dialog")

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.render_cancel (   self) [inherited]
Called when user has hit the cancel button 

Definition at line 172 of file __init__.py.

00172 
00173     def render_cancel(self):
00174         """ Called when user has hit the cancel button """
00175         do_show(self.pagename, self.request)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.render_msg (   self,
  msg,
  msgtype 
) [inherited]
Called to display some message (can also be the action form) 

Definition at line 162 of file __init__.py.

00162 
00163     def render_msg(self, msg, msgtype):
00164         """ Called to display some message (can also be the action form) """
00165         self.request.theme.add_msg(msg, msgtype)
00166         do_show(self.pagename, self.request)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.render_success (   self,
  msg,
  msgtype 
) [inherited]
Called to display some message when the action succeeded 

Definition at line 167 of file __init__.py.

00167 
00168     def render_success(self, msg, msgtype):
00169         """ Called to display some message when the action succeeded """
00170         self.request.theme.add_msg(msg, msgtype)
00171         do_show(self.pagename, self.request)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.ActionBase.ticket_ok (   self) [inherited]
Return True if we check for tickets and there is some valid ticket
    in the form data or if we don't check for tickets at all.
    Use this to make sure someone really used the web interface.

Definition at line 87 of file __init__.py.

00087 
00088     def ticket_ok(self):
00089         """ Return True if we check for tickets and there is some valid ticket
00090             in the form data or if we don't check for tickets at all.
00091             Use this to make sure someone really used the web interface.
00092         """
00093         if not self.use_ticket:
00094             return True
00095         # Require a valid ticket. Make outside attacks harder by
00096         # requiring two full HTTP transactions
00097         ticket = self.form.get('ticket', '')
00098         return wikiutil.checkTicket(self.request, ticket)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 54 of file __init__.py.

Definition at line 51 of file __init__.py.

Reimplemented in MoinMoin.action.Load.Load.

Definition at line 64 of file __init__.py.

Definition at line 62 of file __init__.py.

Definition at line 50 of file __init__.py.

Definition at line 57 of file __init__.py.

Definition at line 58 of file __init__.py.

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 25 of file revert.py.

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 26 of file revert.py.

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 27 of file revert.py.

Reimplemented in MoinMoin.action.Load.Load.

Definition at line 53 of file __init__.py.

Definition at line 49 of file __init__.py.

Reimplemented from MoinMoin.action.ActionBase.

Definition at line 23 of file revert.py.

Definition at line 56 of file __init__.py.


The documentation for this class was generated from the following file: