'Action upon insufficient permissions'

def fail(self):

    if (self.format == 'html'):
        if self.auth.s3_logged_in():
            current.session.error = self.INSUFFICIENT_PRIVILEGES
            redirect(self.homepage)
        else:
            current.session.error = self.AUTHENTICATION_REQUIRED
            redirect(self.loginpage)
    elif self.auth.s3_logged_in():
        raise HTTP(403, body=self.INSUFFICIENT_PRIVILEGES)
    else:
        challenge = {'WWW-Authenticate': (u'Basic    realm="%s"' % current.request.application)}
        raise HTTP(401, body=self.AUTHENTICATION_REQUIRED, **challenge)
