Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.userprefs Namespace Reference

Functions

def _handle_submission
def _create_prefs_page
def _create_page
def execute

Function Documentation

def MoinMoin.action.userprefs._create_page (   request,
  cancel = False 
) [private]

Definition at line 62 of file userprefs.py.

00062 
00063 def _create_page(request, cancel=False):
00064     # returns text, title, msg_class, msg
00065     pagename = request.page.page_name
00066 
00067     if 'handler' in request.values:
00068         msg_class, msg = _handle_submission(request)
00069     else:
00070         msg_class, msg = None, None
00071 
00072     sub = request.args.get('sub', '')
00073     cls = None
00074     if sub and sub not in request.cfg.userprefs_disabled:
00075         try:
00076             cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
00077         except wikiutil.PluginMissingError:
00078             # cls is already None
00079             pass
00080 
00081     obj = cls and cls(request)
00082 
00083     if not obj or not obj.allowed():
00084         return _create_prefs_page(request), None, msg_class, msg
00085 
00086     return obj.create_form(), obj.title, msg_class, msg
00087 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.userprefs._create_prefs_page (   request,
  sel = None 
) [private]

Definition at line 41 of file userprefs.py.

00041 
00042 def _create_prefs_page(request, sel=None):
00043     _ = request.getText
00044     plugins = wikiutil.getPlugins('userprefs', request.cfg)
00045     ret = html.P()
00046     ret.append(html.Text(_("Please choose:")))
00047     ret.append(html.BR())
00048     items = html.UL()
00049     ret.append(items)
00050     for sub in plugins:
00051         if sub in request.cfg.userprefs_disabled:
00052             continue
00053         cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
00054         obj = cls(request)
00055         if not obj.allowed():
00056             continue
00057         url = request.page.url(request, {'action': 'userprefs', 'sub': sub})
00058         lnk = html.LI().append(html.A(href=url).append(html.Text(obj.title)))
00059         items.append(lnk)
00060     return unicode(ret)
00061 

Here is the caller graph for this function:

def MoinMoin.action.userprefs._handle_submission (   request) [private]
Handle GET and POST requests of preferences forms.

Return error msg_class, msg tuple or None, None.

Definition at line 13 of file userprefs.py.

00013 
00014 def _handle_submission(request):
00015     """ Handle GET and POST requests of preferences forms.
00016 
00017     Return error msg_class, msg tuple or None, None.
00018     """
00019     _ = request.getText
00020     sub = request.values.get('handler')
00021 
00022     if sub in request.cfg.userprefs_disabled:
00023         return None, None
00024 
00025     try:
00026         cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
00027     except wikiutil.PluginMissingError:
00028         # we never show this plugin to click on so no need to
00029         # give a message here
00030         return None, None
00031 
00032     obj = cls(request)
00033     if not obj.allowed():
00034         return None, None
00035     res = obj.handle_form()
00036     if isinstance(res, tuple):
00037         return res
00038     # backward compatibility for userprefs plugins,
00039     # they just get 'dialog'-style messages.
00040     return None, res

Here is the caller graph for this function:

def MoinMoin.action.userprefs.execute (   pagename,
  request 
)

Definition at line 88 of file userprefs.py.

00088 
00089 def execute(pagename, request):
00090     _ = request.getText
00091     if not request.user.valid:
00092         actname = __name__.split('.')[-1]
00093         request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
00094         return Page.Page(request, pagename).send_page()
00095 
00096     text, title, msg_class, msg = _create_page(request)
00097     if title:
00098         # XXX: we would like to make "Settings" here a link back
00099         #      to the generic userprefs page but that is impossible
00100         #      due to the way the title is emitted and the theme is
00101         #      responsible for doing the linking....
00102         title = _("Settings") + ":" + title
00103     else:
00104         title = _("Settings")
00105     request.theme.add_msg(msg, msg_class)
00106     request.theme.send_title(title, page=request.page, pagename=pagename)
00107     # Start content (important for RTL support)
00108     request.write(request.formatter.startContent("content"))
00109     request.write(text)
00110     request.write(request.formatter.endContent())
00111     request.theme.send_footer(pagename)
00112     request.theme.send_closing_html()

Here is the call graph for this function: