For example I have this type of functions:

# sono autorizzati i vari manager a seconda della sede
@auth.requires(auth.has_membership('Total-manager') | 
auth.has_membership('Conegliano-studente') | 
auth.has_membership('Pordenone-manager') | 
auth.has_membership('Pordenone-studente') | 
auth.has_membership('Udine-studente'))
def appuntamenti_studente():
     # recupero lo studente selezionato
    studente = request.args(0)
    # recupero il gruppo
    # query per recuperare il nome  dello studente
    query_nome_studente = db.auth_user.id == studente
    # recupero nome e cognome dello studente
    row = 
db(query_nome_studente).select(db.auth_user.first_name,db.auth_user.last_name).first()
    #seleziono gli eventi dello studente
    query = (db.evento.studenti.contains(studente))
    eventi_stud = db(query).select()
    # imposto la grid per far vedere gli eventi dello studente
    exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, 
tsv_with_hidden_cols=False, tsv=False)
    # solo se lo studente corrisponde a chi si รจ loggato
    if (str(auth.user.id) == studente):
        #print 'sono al form normale'
        form = SQLFORM.grid(query, args=[studente], 
fields=[db.evento.titolo, 
db.evento.inizio,db.evento.fine,db.evento.risorsa, 
db.evento.materia,db.evento.docente],create=False, details=False, 
editable=False, deletable=False, maxtextlength=60, exportclasses = 
exportcls)
    else:
        redirect(URL('default','index'))
    return locals()

I'm testing different "fixed" values in the @auth.requires, but they can be 
more or less depending on how many roles are in the db. I'd like to do this 
dynamically from the db, extracting and compising this @auth.requires line 
in dynamic way. Is it possible? Do you have any examples? Thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to