Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes
MoinMoin.userprefs.changepass.Settings Class Reference
Inheritance diagram for MoinMoin.userprefs.changepass.Settings:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.userprefs.changepass.Settings:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def allowed
def handle_form
def create_form
def create_form
def handle_form
def make_form
def make_row

Public Attributes

 request
 cfg
 title
 name

Private Attributes

 _

Detailed Description

Definition at line 16 of file changepass.py.


Constructor & Destructor Documentation

def MoinMoin.userprefs.changepass.Settings.__init__ (   self,
  request 
)
Initialize password change form. 

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 17 of file changepass.py.

00017 
00018     def __init__(self, request):
00019         """ Initialize password change form. """
00020         UserPrefBase.__init__(self, request)
00021         self.request = request
00022         self._ = request.getText
00023         _ = request.getText
00024         self.cfg = request.cfg
00025         self.title = _("Change password")
00026         self.name = 'changepass'
00027 


Member Function Documentation

    Not all preferences are applicable to all users,
    this method is called to determine whether the
    title should be listed or not and whether
    submissions are accepted.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 28 of file changepass.py.

00028 
00029     def allowed(self):
00030         return (not 'password' in self.cfg.user_form_remove and
00031                 not 'password' in self.cfg.user_form_disable and
00032                 UserPrefBase.allowed(self) and
00033                 not 'password' in self.request.user.auth_attribs)
00034 

def MoinMoin.userprefs.UserPrefBase.create_form (   self) [inherited]
    This method should return HTML code for at least
    one form. Each created form *must* contain the
    hidden fields
      * action: set to "userprefs"
      * handler: set to the plugin name
    It can additionally contain the hidden field
    'sub' set to the plugin name if the plugin needs
    multiple forms (wizard-like.)

Reimplemented in MoinMoin.userprefs.prefs.Settings, MoinMoin.userprefs.oid.Settings, MoinMoin.userprefs.notification.Settings, MoinMoin.userprefs.oidserv.Settings, and MoinMoin.userprefs.suid.Settings.

Definition at line 37 of file __init__.py.

00037 
00038     def create_form(self):
00039         '''
00040             This method should return HTML code for at least
00041             one form. Each created form *must* contain the
00042             hidden fields
00043               * action: set to "userprefs"
00044               * handler: set to the plugin name
00045             It can additionally contain the hidden field
00046             'sub' set to the plugin name if the plugin needs
00047             multiple forms (wizard-like.)
00048         '''
00049         raise NotImplementedError

def MoinMoin.userprefs.changepass.Settings.create_form (   self,
  create_only = False,
  recover_only = False 
)
Create the complete HTML form code. 

Definition at line 70 of file changepass.py.

00070 
00071     def create_form(self, create_only=False, recover_only=False):
00072         """ Create the complete HTML form code. """
00073         _ = self._
00074         form = self.make_form(html.Text(_("To change your password, "
00075                                           "enter a new password twice.")))
00076 
00077         self.make_row(_('Password'),
00078                       [html.INPUT(type="password", size=36, name="password1")])
00079         self.make_row(_('Password repeat'),
00080                       [html.INPUT(type="password", size=36, name="password2")])
00081 
00082         # Add buttons
00083         self.make_row('', [
00084                 html.INPUT(type="submit", name='save', value=_("Change password")),
00085                 ' ',
00086                 html.INPUT(type="submit", name='cancel', value=_("Cancel")),
00087               ])
00088 
00089         return unicode(form)

Here is the call graph for this function:

Definition at line 35 of file changepass.py.

00035 
00036     def handle_form(self):
00037         _ = self._
00038         request = self.request
00039         form = request.form
00040 
00041         if form.has_key('cancel'):
00042             return
00043 
00044         if request.method != 'POST':
00045             return
00046 
00047         password = form.get('password1', '')
00048         password2 = form.get('password2', '')
00049 
00050         # Check if password is given and matches with password repeat
00051         if password != password2:
00052             return 'error', _("Passwords don't match!")
00053         if not password:
00054             return 'error', _("Please specify a password!")
00055 
00056         pw_checker = request.cfg.password_checker
00057         if pw_checker:
00058             pw_error = pw_checker(request, request.user.name, password)
00059             if pw_error:
00060                 return 'error', _("Password not acceptable: %s") % pw_error
00061 
00062         try:
00063             self.request.user.enc_password = user.encodePassword(password)
00064             self.request.user.save()
00065             return 'info', _("Your password has been changed.")
00066         except UnicodeError, err:
00067             # Should never happen
00068             return "Can't encode password: %s" % str(err)
00069 

def MoinMoin.userprefs.UserPrefBase.handle_form (   self,
  request 
) [inherited]
    When any of the created forms is submitted and the
    hidden fields are set correctly (see create_form)
    this method will be invoked to handle the user's
    input. Note that GET requests are also handed to
    this method, so if you require POST check that.

Definition at line 50 of file __init__.py.

00050 
00051     def handle_form(self, request):
00052         '''
00053             When any of the created forms is submitted and the
00054             hidden fields are set correctly (see create_form)
00055             this method will be invoked to handle the user's
00056             input. Note that GET requests are also handed to
00057             this method, so if you require POST check that.
00058         '''
00059         raise NotImplementedError

def MoinMoin.userprefs.UserPrefBase.make_form (   self,
  explanation = None 
) [inherited]
    To have a consistent UI, use this method for most
    preferences forms and then call make_row(). See
    existing plugins, e.g. changepass.py.

Definition at line 69 of file __init__.py.

00069 
00070     def make_form(self, explanation=None):
00071         '''
00072             To have a consistent UI, use this method for most
00073             preferences forms and then call make_row(). See
00074             existing plugins, e.g. changepass.py.
00075         '''
00076         action = self.request.page.url(self.request)
00077         _form = html.FORM(action=action)
00078         _form.append(html.INPUT(type="hidden", name="action", value="userprefs"))
00079         _form.append(html.INPUT(type="hidden", name="handler", value=self.name))
00080 
00081         self._table = html.TABLE(border="0")
00082 
00083         # Use the user interface language and direction
00084         lang_attr = self.request.theme.ui_lang_attr()
00085         _form.append(html.Raw('<div class="userpref"%s>' % lang_attr))
00086         para = html.P()
00087         _form.append(para)
00088         if explanation:
00089             para.append(explanation)
00090 
00091         para.append(self._table)
00092         _form.append(html.Raw("</div>"))
00093 
00094         return _form

Here is the caller graph for this function:

def MoinMoin.userprefs.UserPrefBase.make_row (   self,
  label,
  cell,
  kw 
) [inherited]
   Create a row in the form table.

Definition at line 95 of file __init__.py.

00095 
00096     def make_row(self, label, cell, **kw):
00097         '''
00098            Create a row in the form table.
00099         '''
00100         self._table.append(html.TR().extend([
00101             html.TD(**kw).extend([html.B().append(label), '   ']),
00102             html.TD().extend(cell),
00103         ]))

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 21 of file changepass.py.

Definition at line 23 of file changepass.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 25 of file changepass.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 20 of file changepass.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 24 of file changepass.py.


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