Hello again!
I'm facing an issue whith the example of non-CRUD forms in docs. Doesn't look like an error in the logic of the controller. The code is based in the example posted here
What I'm trying to do is tho create a custom form (non-crud) with some fields.
@action("carga_combinada")
@action.uses("generic.html", flash)
def carga_combinada():
# declaro los ROLES para poder usarlos en el formulario non-CRUD
ROLES = ["DBA", "Analista", "Diseñador", "Front end", "Programador"]
fields = [Field("nombre"),
Field("rol", requires=IS_IN_SET(ROLES)),
Field("descripcion",
requires=IS_NOT_EMPTY(error_message="¡Epa! Te olvidaste de completar qué se va a hacer"),
label="Descripción"),
Field("inicio", "datetime"),
Field("estimacion", "integer",
label="Estimación",
comment = "Duración estimada de la tarea en horas")]
form = Form(fields)
if form.accepted:
flash.set("La información se cargó correctamente")
redirect(URL("index"))
return locals()
When I load the action with a development server, it raises an error with this traceback.
Traceback (most recent call last):
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 1059, in wrapper
ret = func(*func_args, **func_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 1044, in wrapper
raise exception
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 1037, in wrapper
call_f(fixture.on_success, context)
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 1002, in call_f
return f(context)
^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 626, in on_success
context["output"] = render(
^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/py4web/core.py", line 588, in render
return engine.render(filename, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/renoir/apis.py", line 172, in render
return self._render(source, file_path, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/renoir/apis.py", line 166, in _render
make_traceback(exc_info)
File "/home/alan/py4web_venv/lib/python3.12/site-packages/renoir/debug.py", line 114, in make_traceback
reraise(exc_type, exc_value, tb)
File "/home/alan/py4web_venv/lib/python3.12/site-packages/renoir/_internal.py", line 15, in reraise
raise value.with_traceback(tb)
File "/home/alan/Proyectos/py4web/apps/formularios/templates/generic.html", line 11, in template
[[=BEAUTIFY(__vars__)]]
File "/home/alan/py4web_venv/lib/python3.12/site-packages/yatl/helpers.py", line 583, in BEAUTIFY
TBODY(*[TR(TH(key), TD(BEAUTIFY(value))) for key, value in obj.items()])
^^^^^^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/yatl/helpers.py", line 580, in BEAUTIFY
return UL(*[LI(BEAUTIFY(item)) for item in obj])
^^^^^^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/yatl/helpers.py", line 588, in BEAUTIFY
return repr(obj)
^^^^^^^^^
File "/home/alan/py4web_venv/lib/python3.12/site-packages/pydal/objects.py", line 1676, in __repr__
return str(self.db._adapter.expand(self, self.type))
^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_adapter'
Added the complete controller code and the ticket report
Regards
Alan