Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 request
 cfg
 title
 name

Private Member Functions

def _handle_remove
def _make_form
def _make_row
def _trust_root_list

Private Attributes

 _
 _table

Detailed Description

Definition at line 15 of file oidserv.py.


Constructor & Destructor Documentation

def MoinMoin.userprefs.oidserv.Settings.__init__ (   self,
  request 
)
Initialize OpenID settings form. 

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 16 of file oidserv.py.

00016 
00017     def __init__(self, request):
00018         """ Initialize OpenID settings form. """
00019         UserPrefBase.__init__(self, request)
00020         self.request = request
00021         self._ = request.getText
00022         self.cfg = request.cfg
00023         _ = self._
00024         self.title = _("OpenID server")


Member Function Documentation

Definition at line 37 of file oidserv.py.

00037 
00038     def _handle_remove(self):
00039         _ = self.request.getText
00040         if not hasattr(self.request.user, 'openid_trusted_roots'):
00041             return
00042         roots = self.request.user.openid_trusted_roots[:]
00043         for root in self.request.user.openid_trusted_roots:
00044             name = "rm-%s" % root
00045             if name in self.request.form:
00046                 roots.remove(root)
00047         self.request.user.openid_trusted_roots = roots
00048         self.request.user.save()
00049         return 'info', _("The selected websites have been removed.")

Here is the caller graph for this function:

Definition at line 63 of file oidserv.py.

00063 
00064     def _make_form(self):
00065         sn = self.request.script_root
00066         pi = self.request.getPathinfo()
00067         action = u"%s%s" % (sn, pi)
00068         _form = html.FORM(action=action)
00069         _form.append(html.INPUT(type="hidden", name="action", value="userprefs"))
00070         _form.append(html.INPUT(type="hidden", name="handler", value="oidserv"))
00071         return _form

Here is the caller graph for this function:

def MoinMoin.userprefs.oidserv.Settings._make_row (   self,
  label,
  cell,
  kw 
) [private]
Create a row in the form table.

Definition at line 72 of file oidserv.py.

00072 
00073     def _make_row(self, label, cell, **kw):
00074         """ Create a row in the form table.
00075         """
00076         self._table.append(html.TR().extend([
00077             html.TD(**kw).extend([html.B().append(label), '   ']),
00078             html.TD().extend(cell),
00079         ]))

Here is the caller graph for this function:

Definition at line 80 of file oidserv.py.

00080 
00081     def _trust_root_list(self):
00082         _ = self.request.getText
00083         form = self._make_form()
00084         for root in self.request.user.openid_trusted_roots:
00085             display = base64.decodestring(root)
00086             name = 'rm-%s' % root
00087             form.append(html.INPUT(type="checkbox", name=name, id=name))
00088             form.append(html.LABEL(for_=name).append(html.Text(display)))
00089             form.append(html.BR())
00090         self._make_row(_("Trusted websites"), [form], valign='top')
00091         label = _("Remove selected")
00092         form.append(html.BR())
00093         form.append(html.INPUT(type="submit", name="remove", value=label))

Here is the call graph for this function:

    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 25 of file oidserv.py.

00025 
00026     def allowed(self):
00027         if not self.request.cfg.openid_server_enabled:
00028             return False
00029 
00030         groups = self.request.groups
00031         openid_group_name = self.request.cfg.openid_server_restricted_users_group
00032 
00033         if openid_group_name and self.request.user.name not in groups.get(openid_group_name, []):
00034                 return False
00035 
00036         return True

Create the complete HTML form code. 

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 94 of file oidserv.py.

00094 
00095     def create_form(self):
00096         """ Create the complete HTML form code. """
00097         _ = self._
00098 
00099         ret = html.P()
00100         # Use the user interface language and direction
00101         lang_attr = self.request.theme.ui_lang_attr()
00102         ret.append(html.Raw('<div %s>' % lang_attr))
00103         self._table = html.TABLE(border="0")
00104         ret.append(self._table)
00105         ret.append(html.Raw("</div>"))
00106 
00107         request = self.request
00108 
00109         if hasattr(request.user, 'openid_trusted_roots') and request.user.openid_trusted_roots:
00110             self._trust_root_list()
00111 
00112         form = self._make_form()
00113         label = _("Cancel")
00114         form.append(html.INPUT(type="submit", name='cancel', value=label))
00115         self._make_row('', [form])
00116         return unicode(ret)
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

Definition at line 50 of file oidserv.py.

00050 
00051     def handle_form(self):
00052         _ = self._
00053         form = self.request.form
00054 
00055         if form.has_key('cancel'):
00056             return
00057 
00058         if self.request.request_method != 'POST':
00059             return
00060 
00061         if form.has_key('remove'):
00062             return self._handle_remove()

Here is the call graph for this function:

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 20 of file oidserv.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 102 of file oidserv.py.

Definition at line 21 of file oidserv.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 19 of file oidserv.py.

Reimplemented from MoinMoin.userprefs.UserPrefBase.

Definition at line 23 of file oidserv.py.


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