Hello,

I've made an application where I call a MySQL database and give the user 
the option of choosing the columns of the database to appear. Nevertheless 
when I try to click the link I get the "Not authorized Insufficient 
privileges" error without even having the chance to login. 

I used @auth.requires_membership('manager') in order to allow only certain 
users to access the database but that's not the problem as when i comment 
this line i still get the error.

My I kept the default db.py and made a new one named lcdb.py as follows:

lcdb.define_table('new_lung_cancer',
    Field('id','string'),
    Field('patient_code','string'),
    ....
    ....
    Field('wet_tissue','string'),
    migrate=False)

The function in the default.py controller is the following:

@auth.requires_membership('manager')
def data():
    response.flash = ("Συγκεντρωτικός Πίνακας Δεδομένων")
    #define the names of the columns as mysql only accepts latin letters 
and no gaps
    headers={'new_lung_cancer.id':'A/A', 
'new_lung_cancer.patient_code':'ΚΩΔΙΚΟΣ ΑΣΘΕΝΟΥΣ', 
'new_lung_cancer.age':'ΗΛΙΚΙΑ', 
                         ...
                         ...
                         ...
                     'new_lung_cancer.wet_tissue':'ΝΩΠΟΣ ΙΣΤΟΣ'}

    #define a list of columns from which the dropdown menu will get its 
input when the user chooses which columns to display
    fields_temp=[lcdb.new_lung_cancer.id,    
lcdb.new_lung_cancer.patient_code,   ...,    
lcdb.new_lung_cancer.wet_tissue]

    #this is where the column info will go in order for the sqlform command 
to display the appropriate columns
    fields=[]

    #create a list of indices corresponding to the columns
    answers=range(len(fields_temp))
    #create the dropdown menu without creating a database in Mysql
    form = SQLFORM.factory(Field('options', 
requires=IS_IN_SET((answers),('A/A', 'ΚΩΔΙΚΟΣ ΑΣΘΕΝΟΥΣ', 'ΗΛΙΚΙΑ', ... 
'ΙΣΤΟΣ ΠΑΡΑΦΙΝΗ', 'ΝΩΠΟΣ ΙΣΤΟΣ'), multiple=True)))

    #If the user chooses one column or more than one column is defined by 
this. In case the user press submit without choosing something all the 
database is displayed
    if form.accepts(request.vars,session):
        if type(request.vars.options).__name__=='list':
            for option in request.vars.options:
                fields.append(fields_temp[int(option)])
        elif type(request.vars.options).__name__=='str':         #this is 
esssential for when the indice of the selection has more than one digit
            fields.append(fields_temp[int(request.vars.options)])
        else:
            response.flash = 'Please select a column'
            form2=SQLFORM.grid(lcdb.new_lung_cancer, headers=headers, 
create=True, deletable=False, editable=False, maxtextlength=32, paginate=10)

        form2=SQLFORM.grid(lcdb.new_lung_cancer, headers=headers, 
fields=fields, create=True, deletable=False, editable=False, 
maxtextlength=32, paginate=10)

    elif form.errors:
        response.flash = 'Form has errors' #just in case
    else:
        form2=SQLFORM.grid(lcdb.new_lung_cancer, headers=headers, 
create=True, deletable=False, editable=False, maxtextlength=32, paginate=10)
    return dict(form=form, form2=form2)


The thing is i used the exact same function for a different MySQL database 
(by changing the names of fields) and it worked perfectly.

What am I missing? Where could i be getting the error from if not from Auth?

P.S. I'm using "..." in my post in order not to make it chaotic with all 
the different fields and field names. If you need the whole code I can 
attach it.

-- 
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