I have a generic controller to show the contents of a table in a grid.  For
one of the 33 tables I get this error while the other seems to work without
problem:

Controller:

@auth.requires_login()
def show_data():
       tabel = request.vars.tabel.lower()
       data= plugin_wiki.widget('jqgrid',table=tabel,width=950)
       return dict(data=data,tabel=tabel)

@auth.requires_login()
def captured_data():
       form = SQLFORM.factory(Field('tabel', requires =
IS_IN_DB(db,db.label.form_id,groupby = 'form_id'),
                                   label = "Which forms?"),
                             )
       if form.accepts(request.vars, session):
              redirect(URL(r=request, f='show_data',vars=request.vars))
       elif form.errors:
              response.flash = 'form has errors'
       return dict(form = form)

Model of the problem table:


db.define_table("gr03",
                Field("observer_or_trainer"),
                Field("service_provider",db.service_provider,
                      requires=IS_IN_DB(db,db.service_provider.id,
'%(name)s'),label="Service provider"),
                Field("date","date"),
                Field("school",db.school,label="School",
                      requires=IS_IN_DB(db,db.school.id, '%(name)s')),
                Field("teacher",db.teacher,
                      requires=IS_IN_DB(db,db.teacher.id,
'%(school)s,%(surname)s,%(name)s')),
                Field("focus",label="Topic/focus"),
                Field("assessment_standard",label="2. Assessment Standard"),
                Field("q3","text",
                      label=SPAN("3. Content knowledge for teacher")
                      ),
                Field("q4","text",
                      label=SPAN("4. Teaching skills of
teacher",BR(),spasies(4),
                                 "(include use of resources)")
                      ),
                Field("q5","text",
                      label=SPAN("5. Overall finding"),
                      ),

                Field("q7","text"),
                Field("q8","text"),
                Field("q9","text"),
                Field("q10","text"),
                )

What is a bit strange to me is that the line in the controller referred to
by the ticket is the last line of the file and not in the vicinity of the
controller involved.

The ticket:

Traceback (most recent call last):

  File "/Users/js/Programmeer/zenex/web2py/gluon/restricted.py", line
188, in restricted
    exec ccode in environment
  File 
"/Users/js/Programmeer/zenex/web2py/applications/zenex2/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/zenex2/controllers/default.py>,
line 1402, in <module>
  File "/Users/js/Programmeer/zenex/web2py/gluon/globals.py", line 96,
in <lambda>
    self._caller = lambda f: f()
  File "/Users/js/Programmeer/zenex/web2py/gluon/tools.py", line 2272, in f
    return action(*a, **b)
  File 
"/Users/js/Programmeer/zenex/web2py/applications/zenex2/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/zenex2/controllers/default.py>,
line 827, in show_data
    data= plugin_wiki.widget('jqgrid',table=tabel,width=950)
  File 
"/Users/js/Programmeer/zenex/web2py/applications/zenex2/models/plugin_wiki.py"
<http://127.0.0.1:8000/admin/default/edit/zenex2/models/plugin_wiki.py>,
line 675, in widget
    return getattr(PluginWikiWidgets,name)(*args,**kargs)
  File 
"/Users/js/Programmeer/zenex/web2py/applications/zenex2/models/plugin_wiki.py"
<http://127.0.0.1:8000/admin/default/edit/zenex2/models/plugin_wiki.py>,
line 280, in jqgrid
    """ % dict(callback=callback,colnames=json(colnames),
  File "/Users/js/Programmeer/zenex/web2py/gluon/serializers.py", line
31, in json
    return simplejson.dumps(value)
  File 
"/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/__init__.py",
line 228, in dumps
    return _default_encoder.encode(obj)
  File "/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/encoder.py",
line 232, in encode
    chunks = list(chunks)
  File "/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/encoder.py",
line 498, in _iterencode
    for chunk in _iterencode_list(o, _current_indent_level):
  File "/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/encoder.py",
line 396, in _iterencode_list
    for chunk in chunks:
  File "/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/encoder.py",
line 511, in _iterencode
    o = _default(o)
  File "/Users/js/Programmeer/zenex/web2py/gluon/contrib/simplejson/encoder.py",
line 206, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError:  is not JSON serializable


I have no idea where to look for the problem.  In the appadmin everything
seems to work OK.

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