Back to index

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

Functions

def execute

Function Documentation

def MoinMoin.action.subscribe.execute (   pagename,
  request 
)
Subscribe the user to pagename 

Definition at line 11 of file subscribe.py.

00011 
00012 def execute(pagename, request):
00013     """ Subscribe the user to pagename """
00014     _ = request.getText
00015     if not request.user.valid:
00016         actname = __name__.split('.')[-1]
00017         request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
00018         return Page(request, pagename).send_page()
00019 
00020     cfg = request.cfg
00021 
00022     if not request.user.may.read(pagename):
00023         request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error")
00024 
00025     # Check if mail is enabled
00026     elif not cfg.mail_enabled and not cfg.jabber_enabled:
00027         request.theme.add_msg(_("This wiki is not enabled for mail/Jabber processing."), "error")
00028 
00029     # Suggest visitors to login
00030     elif not request.user.valid:
00031         request.theme.add_msg(_("You must log in to use subscriptions."), "error")
00032 
00033     # Suggest users without email to add their email address
00034     elif not request.user.email and not request.user.jid:
00035         request.theme.add_msg(_("Add your email address or Jabber ID in your user settings to use subscriptions."),
00036                               "error")
00037 
00038     elif request.user.isSubscribedTo([pagename]):
00039         request.theme.add_msg(_('You are already subscribed to this page.'))
00040     else:
00041         # Try to subscribe
00042         if request.user.subscribe(pagename):
00043             request.theme.add_msg(_('You have been subscribed to this page.'), "info")
00044         else: # should not happen
00045             request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
00046 
00047     Page(request, pagename).send_page()