'Generate a form to send a message
@param r: the S3Request instance
@param attr: controller attributes for the request'

def compose(self, r, **attr):

    T = current.T
    auth = current.auth
    self.url = url = r.url()
    if (auth.is_logged_in() or auth.basic()):
        pass
    else:
        redirect(URL(c='default', f='user', args='login', vars={'_next': url}))
    if (not current.deployment_settings.has_module('msg')):
        current.session.error = T('Cannot    send    messages    if    Messaging    module    disabled')
        redirect(URL(f='index'))
    if (not auth.permission.has_permission('update', c='msg')):
        current.session.error = T('You    do    not    have    permission    to    send    messages')
        redirect(URL(f='index'))
    self.contact_method = None
    self.recipient = None
    self.recipients = None
    self.recipient_type = None
    self.subject = None
    self.message = None
    form = self._compose_form()
    if (self.method == 'compose'):
        output = dict(form=form)
    else:
        r.error(405, current.ERROR.BAD_METHOD)
    if (r.representation == 'html'):
        title = self.crud_string(self.tablename, 'title_compose')
        if (not title):
            title = T('Send    Message')
        if attr.get('rheader'):
            rheader = attr['rheader'](r)
            if rheader:
                output['rheader'] = rheader
        output['title'] = title
        current.response.view = self._view(r, 'create.html')
    return output
