#3: js_callback not JSON serializable?
------------------------+---------------------------------------------------
Reporter: lmacken | Owner: sanjiv
Type: defect | Status: new
Priority: major | Milestone:
Component: component1 | Version:
Keywords: activeform |
------------------------+---------------------------------------------------
Hi, I'm encountering a problem when trying to use the
tw.jquery.activeform.AjaxForm. With the following form
{{{
class NewUpdateWidget(AjaxForm):
success = js_callback('newupdate_success')
action = 'save'
class fields(WidgetsList):
title = TextField(validator=formencode.All(validators.NotEmpty(),
validators.UnicodeString()))
bugs = TextField(validator=validators.UnicodeString())
types = ('bugfix', 'enhancement', 'security', 'newpackage')
type = SingleSelectField(options=types,
validator=validators.OneOf(types))
requests = ('Testing', 'Stable')
request = SingleSelectField(options=requests,
validator=validators.OneOf(requests))
notes = TextArea(validator=validators.UnicodeString())
}}}
I receive the following traceback:
{{{
File '/usr/local/myfedora/tg2/lib/python2.5/site-
packages/WebError-0.9-py2.5.egg/weberror/evalexception.py', line 428 in
respond
app_iter = self.application(environ, detect_start_response)
File '/usr/local/myfedora/tg2/tg2/tg/configuration.py', line 357 in
remover
return app(environ, start_response)
File '/usr/local/myfedora/tg2/lib/python2.5/site-
packages/repoze.tm2-1.0a3-py2.5.egg/repoze/tm/__init__.py', line 19 in
__call__
result = self.application(environ, save_status_and_headers)
File '/usr/local/myfedora/tg2/lib/python2.5/site-
packages/repoze.who-1.0.2-py2.5.egg/repoze/who/middleware.py', line 105 in
__call__
app_iter = app(environ, wrapper.wrap_start_response)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/middleware.py', line 36
in __call__
return self.wsgi_app(environ, start_response)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/middleware.py', line 59
in wsgi_app
resp = req.get_response(self.application)
File 'build/bdist.linux-x86_64/egg/webob/__init__.py', line 1307 in
get_response
File 'build/bdist.linux-x86_64/egg/webob/__init__.py', line 1275 in
call_application
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/resource_injector.py',
line 72 in _injector
resp.body = inject_resources(resp.body, resources, resp.charset)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/resource_injector.py',
line 116 in __call__
html = MultipleReplacer.__call__(self, html, resources, encoding)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/util.py', line 405 in
__call__
return self._regexp.sub(self._subsitutor(*args, **kw), string)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/util.py', line 401 in
substitutor
return substitutor(group, *args, **kw)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/resource_injector.py',
line 88 in inject
inj = u'\n'.join(r.render() for r in resources.get(key, []))
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/resource_injector.py',
line 88 in <genexpr>
inj = u'\n'.join(r.render() for r in resources.get(key, []))
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/base.py', line 514 in
render
kw = self.prepare_dict(value, kw)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/base.py', line 573 in
prepare_dict
self.update_params(d)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/resources.py', line 403
in update_params
map(str, chain(self.call_getter(self.location), d.function_calls))
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/js.py', line 217 in
__str__
return '.'.join(c.__get_js_repr() for c in self.__call_list)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/js.py', line 217 in
<genexpr>
return '.'.join(c.__get_js_repr() for c in self.__call_list)
File '/usr/local/myfedora/tg2/ToscaWidgets/tw/core/js.py', line 210 in
__get_js_repr
return '%s(%s)' % (self.__name, ', '.join(imap(encode, args)))
File 'build/bdist.linux-x86_64/egg/simplejson/encoder.py', line 196 in
encode
File 'build/bdist.linux-x86_64/egg/simplejson/encoder.py', line 255 in
iterencode
File 'build/bdist.linux-x86_64/egg/simplejson/encoder.py', line 173 in
default
TypeError: <tw.core.js.js_callback object at 0x271bfd0> is not JSON
serializable
}}}
--
Ticket URL: <http://toscawidgets.org/trac/tw.jquery/ticket/3>
tw.jquery </trac/tw.jquery>
tw.jquery