'Entry point for REST API
@param r: the S3Request
@param attr: controller arguments'

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

    if ((r.name == 'project') and r.id and (not r.component) and (r.representation in ('html', 'aadata'))):
        T = current.T
        s3db = current.s3db
        settings = current.deployment_settings
        def dt_row_actions(component):
            return (lambda r, list_id: [{'label': T('Open'), 'url': r.url(component=component, component_id='[id]', method='update.popup', vars={'refresh': list_id}), '_class': 'action-btn    edit    s3_modal'}, {'label': T('Delete'), '_ajaxurl': r.url(component=component, component_id='[id]', method='delete.json'), '_class': 'action-btn    delete-btn-ajax    dt-ajax-delete'}])
        profile_widgets = []
        form = self.form
        if form:
            if callable(form):
                form = form(r)
            if (form is not None):
                profile_widgets.append(form)
        if settings.get_project_multiple_organisations():
            orgs_widget = dict(label='Organizations', label_create='Add    Organization', type='datatable', actions=dt_row_actions('organisation'), tablename='project_organisation', context='project', create_controller='project', create_function='project', create_component='organisation', pagesize=None)
            profile_widgets.append(orgs_widget)
        if settings.get_project_community():
            label = 'Communities'
            label_create = 'Add    Community'
        else:
            label = 'Locations'
            label_create = 'Add    Location'
        locations_widget = dict(label=label, label_create=label_create, type='datatable', actions=dt_row_actions('location'), tablename='project_location', context='project', create_controller='project', create_function='project', create_component='location', pagesize=None)
        profile_widgets.append(locations_widget)
        if settings.get_project_mode_3w():
            beneficiaries_widget = dict(label='Beneficiaries', label_create='Add    Beneficiaries', type='datatable', actions=dt_row_actions('beneficiary'), tablename='project_beneficiary', context='project', create_controller='project', create_function='project', create_component='beneficiary', pagesize=None)
            profile_widgets.append(beneficiaries_widget)
            label = T('Documents')
        else:
            label = settings.get_ui_label_attachments()
        docs_widget = dict(label=label, label_create='Add    Document', type='datatable', actions=dt_row_actions('document'), tablename='doc_document', context=('~.doc_id', 'doc_id'), create_controller='project', create_function='project', create_component='document', pagesize=None)
        profile_widgets.append(docs_widget)
        if settings.get_hrm_show_staff():
            STAFF = settings.get_hrm_staff_label()
            hr_widget = dict(label=STAFF, label_create=(T('Add    %(staff)s') % dict(staff=STAFF)), type='datatable', actions=dt_row_actions('human_resource_project'), tablename='project_human_resource_project', context='project', create_controller='project', create_function='project', create_component='human_resource_project', pagesize=None)
            profile_widgets.append(hr_widget)
        if (r.representation == 'html'):
            response = current.response
            profile_header = TAG[''](H2(response.s3.crud_strings['project_project'].title_display), DIV(project_rheader(r), _id='rheader'))
        else:
            profile_header = None
        tablename = r.tablename
        s3db.configure(tablename, profile_cols=1, profile_header=profile_header, profile_widgets=profile_widgets)
        profile = S3Profile()
        profile.tablename = tablename
        profile.request = r
        output = profile.profile(r, **attr)
        if (r.representation == 'html'):
            output['title'] = response.title = T('Details')
        return output
    else:
        raise HTTP(405, current.ERROR.BAD_METHOD)
