Hi guys!
I’m curious as to what the following code inside indico.modules.events.sessions.forms.SessionForm’s __init__
method is supposed to do/take care of?
if event.type != 'conference':
del self.code
del self.type
else:
self.type.query = SessionType.query.with_parent(event)
if not self.type.query.has_rows():
del self.type
I am trying to create an InvoiceForm, which is basically a copy of SessionForm (with changed text, etc.), but if I remove the above code from __init__
, I get an Exception:
TypeError: ‘NoneType’ object is not callable
Stack:
Traceback (most recent call last):
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception
return handler(e)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/util.py", line 194, in wrapped
return func(*args, **kwargs)
File "/home/user/dev/indico/src/indico/web/flask/util.py", line 84, in wrapper
return obj().process()
File "/home/user/dev/indico/src/indico/web/rh.py", line 275, in process
res = self._do_process()
File "/home/user/dev/indico/src/indico/web/rh.py", line 245, in _do_process
rv = self._process()
File "/home/user/dev/indico/plugins/my/invoices/indico_invoices/controllers.py", line 51, in _process
return jsonify_form(form)
File "/home/user/dev/indico/src/indico/web/util.py", line 78, in jsonify_form
footer_align_right=footer_align_right, disable_if_locked=disable_if_locked)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 575, in __call__
return self._invoke(arguments, autoescape)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/util.py", line 154, in decorator
return func(*args, **kwargs)
File "/home/user/dev/indico/src/indico/web/templates/forms/_form.html", line 619, in macro
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/templating.py", line 108, in call
return super(PluginJinjaContext, __self).call(__obj, *args, **kwargs)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 575, in __call__
return self._invoke(arguments, autoescape)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/util.py", line 154, in decorator
return func(*args, **kwargs)
File "/home/user/dev/indico/src/indico/web/templates/forms/_form.html", line 418, in macro
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/templating.py", line 108, in call
return super(PluginJinjaContext, __self).call(__obj, *args, **kwargs)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 575, in __call__
return self._invoke(arguments, autoescape)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/util.py", line 154, in decorator
return func(*args, **kwargs)
File "/home/user/dev/indico/src/indico/web/templates/forms/_form.html", line 382, in macro
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/templating.py", line 108, in call
return super(PluginJinjaContext, __self).call(__obj, *args, **kwargs)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 575, in __call__
return self._invoke(arguments, autoescape)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/util.py", line 154, in decorator
return func(*args, **kwargs)
File "/home/user/dev/indico/src/indico/web/templates/forms/_form.html", line 220, in macro
File "/home/user/dev/indico/env/lib/python2.7/site-packages/flask_pluginengine/templating.py", line 108, in call
return super(PluginJinjaContext, __self).call(__obj, *args, **kwargs)
File "/home/user/dev/indico/src/indico/web/forms/jinja_helpers.py", line 91, in render_field
return field(**args)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/wtforms/fields/core.py", line 155, in __call__
return self.meta.render_field(self, kwargs)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/wtforms/meta.py", line 56, in render_field
return field.widget(field, **render_kw)
File "/home/user/dev/indico/env/lib/python2.7/site-packages/wtforms/widgets/core.py", line 323, in __call__
for val, label, selected in field.iter_choices():
File "/home/user/dev/indico/env/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/fields.py", line 107, in iter_choices
for pk, obj in self._get_object_list():
File "/home/user/dev/indico/env/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/fields.py", line 98, in _get_object_list
query = self.query or self.query_factory()
TypeError: 'NoneType' object is not callable