Back to index

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

Functions

def execute

Function Documentation

def MoinMoin.action.unsubscribe.execute (   pagename,
  request 
)
Unsubscribe the user from pagename 

Definition at line 11 of file unsubscribe.py.

00011 
00012 def execute(pagename, request):
00013     """ Unsubscribe the user from 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     if request.user.isSubscribedTo([pagename]):
00021         # Try to unsubscribe
00022         if request.user.unsubscribe(pagename):
00023             request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
00024         else:
00025             msg = _("Can't remove regular expression subscription!") + u' ' + \
00026                   _("Edit the subscription regular expressions in your settings.")
00027             request.theme.add_msg(msg, "error")
00028     else:
00029         # The user is not subscribed
00030         request.theme.add_msg(_('You need to be subscribed to unsubscribe.'), "info")
00031     Page(request, pagename).send_page()
00032