"""Common routines for logging in and logging out of the list administrator
and list moderator interface.
"""
from Mailman import mm_cfg
from Mailman import Utils
from Mailman import Errors
from Mailman.htmlformat import FontAttr
from Mailman.i18n import _
class NotLoggedInError(Exception):
"""Exception raised when no matching admin cookie was found."""
def __init__(self, message):
Exception.__init__(self, message)
self.message = message
def loginpage(mlist, scriptname, msg='', frontpage=None):
url = mlist.GetScriptURL(scriptname)
if frontpage:
actionurl = url
else:
actionurl = Utils.GetRequestURI(url)
if msg:
msg = FontAttr(msg, color='#ff0000', size='+1').Format()
if scriptname == 'admindb':
who = _('Moderator')
else:
who = _('Administrator')
charset = Utils.GetCharSet(mlist.preferred_language)
print 'Content-type: text/html; charset=' + charset + '\n\n'
print Utils.maketext(
'admlogin.html',
{'listname': mlist.real_name,
'path' : actionurl,
'message' : msg,
'who' : who,
}, mlist=mlist)
print mlist.GetMailmanFooter()