Certain users may view data of the service providers in their provinces -
that is of tables with a service_provider field.

When I run this code on the command line all works as expected (data
contains a SQLTABLE).  However when I run it in the web-interface the result
is a page with

<html>
<head>
</head>
<body>
None
</body>
</html>

This happens only when I log in as one of the provincial managers (using the
if...  in the controller below).
Other users with different permissions do not have the same problem.

Controller:

@auth.requires_login()
def show_data():
       tabel = request.vars.tabel #requested tablename in uppercase.
       tb = tabel.lower()
       isps = provinsiaal() # a function returning a list of isp-id's the
manager is supposed to see.
       if isps:
              # provincial manager
              if tb in tabelle_met_sp:       # tabelle_met_sp = tables using
the normal fieldname: 'service_provider'
                     data =
SQLTABLE(db(db[tb].service_provider.belongs(isps)).select())
              else:
                     if tb in tabelle_met_sp_onder_ander_naam.keys():
                            spnaam = tabelle_met_sp_onder_ander_naam[tb]
#tables using other fieldnames for the same data
                            data =
SQLTABLE(db(db[tb][spnaam].belongs(isps)).select())
                     else:
                            data = 'Something is wrong'
       else:

              wie = db(db.auth_user.id ==
auth.user_id).select(db.auth_user.username).first()['username']
              try:
                     sp = db(db.service_provider.name== wie).select(
db.service_provider.id).first()['id']
                     if tb in tabelle_met_sp:
                            data=
plugin_wiki.widget('jqgrid',col_width=130,table=tabel.lower(),
                                                     fieldname =
'service_provider',
                                                     fieldvalue = sp,
                                                     width=950)
                     elif tb in tabelle_met_sp_onder_ander_naam.keys():
                            data=
plugin_wiki.widget('jqgrid',col_width=130,table=tabel.lower(),
                                                     fieldname =
tabelle_met_sp_onder_ander_naam[tb],
                                                     fieldvalue = sp,
                                                     width=950)
                     else:
                            data =
plugin_wiki.widget('jqgrid',col_width=130,table=tabel.lower(),
                                                      width=950)
              except:
                     data =
plugin_wiki.widget('jqgrid',col_width=130,table=tabel.lower(),
                                               width=950)
              return dict(data=data,tabel=tabel)

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
                                                    2 Pet. 1:2b,3a

Reply via email to