def problem():
    ' Problem REST Controller '
    tablename = ('%s_%s' % (module, resourcename))
    table = s3db[tablename]
    set_method = s3db.set_method
    set_method(module, resourcename, method='problems', action=problems)
    set_method(module, resourcename, method='discuss', action=discuss)
    set_method(module, resourcename, component_name='solution', method='discuss', action=discuss)
    set_method(module, resourcename, method='vote', action=vote)
    set_method(module, resourcename, method='results', action=results)
    s3.filter = (table.active == True)
    if (not s3_has_role('DelphiAdmin')):
        s3db.configure(tablename, deletable=False)

    def prep(r):
        if r.interactive:
            if r.record:
                duser = s3db.delphi_DelphiUser(r.record.group_id)
                if duser.authorised:
                    s3db.configure(tablename, deletable=True)
            if (r.component_name == 'solution'):
                r.component.table.modified_on.label = T('Last Updated')
                s3db.configure(r.component.tablename, deletable=duser.authorised)
        return True
    s3.prep = prep

    def postp(r, output):
        if r.interactive:
            if (not r.component):
                s3.actions = [dict(label=str(T('Solutions')), _class='action-btn', url=URL(args=['[id]', 'solution'])), dict(label=str(T('Vote')), _class='action-btn', url=URL(args=['[id]', 'vote']))]
            elif (r.component_name == 'solution'):
                s3.actions = [dict(label=str(T('Discuss')), _class='action-btn', url=URL(args=[r.id, 'solution', '[id]', 'discuss']))]
        return output
    s3.postp = postp
    rheader = problem_rheader
    return s3_rest_controller(rheader=rheader)
Problem REST Controller
def problem():
    '  '
    tablename = ('%s_%s' % (module, resourcename))
    table = s3db[tablename]
    set_method = s3db.set_method
    set_method(module, resourcename, method='problems', action=problems)
    set_method(module, resourcename, method='discuss', action=discuss)
    set_method(module, resourcename, component_name='solution', method='discuss', action=discuss)
    set_method(module, resourcename, method='vote', action=vote)
    set_method(module, resourcename, method='results', action=results)
    s3.filter = (table.active == True)
    if (not s3_has_role('DelphiAdmin')):
        s3db.configure(tablename, deletable=False)

    def prep(r):
        if r.interactive:
            if r.record:
                duser = s3db.delphi_DelphiUser(r.record.group_id)
                if duser.authorised:
                    s3db.configure(tablename, deletable=True)
            if (r.component_name == 'solution'):
                r.component.table.modified_on.label = T('Last Updated')
                s3db.configure(r.component.tablename, deletable=duser.authorised)
        return True
    s3.prep = prep

    def postp(r, output):
        if r.interactive:
            if (not r.component):
                s3.actions = [dict(label=str(T('Solutions')), _class='action-btn', url=URL(args=['[id]', 'solution'])), dict(label=str(T('Vote')), _class='action-btn', url=URL(args=['[id]', 'vote']))]
            elif (r.component_name == 'solution'):
                s3.actions = [dict(label=str(T('Discuss')), _class='action-btn', url=URL(args=[r.id, 'solution', '[id]', 'discuss']))]
        return output
    s3.postp = postp
    rheader = problem_rheader
    return s3_rest_controller(rheader=rheader)