Skip to content

Commit

Permalink
forgiving forms for use in console
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Feb 9, 2025
1 parent b540e88 commit f20abb3
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions py4web/utils/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
import jwt
from pydal._compat import to_native
from pydal.objects import FieldVirtual
from yatl.helpers import (CAT, DIV, FORM, INPUT, LABEL, OPTION, SELECT, SPAN,
TEXTAREA, XML, A, P)
from yatl.helpers import (
CAT,
DIV,
FORM,
INPUT,
LABEL,
OPTION,
SELECT,
SPAN,
TEXTAREA,
XML,
A,
P,
)

from py4web import HTTP, request, response
from py4web.utils.param import Param
Expand Down Expand Up @@ -774,8 +786,15 @@ def __init__(
self.vars = self._read_vars_from_record(table)

if not readonly:
post_vars = request.GET if self.method == "GET" else request.POST
form_vars = copy.deepcopy(request.forms)
try:
post_vars = request.GET if self.method == "GET" else request.POST
except KeyError:
post_vars = {}

try:
form_vars = copy.deepcopy(request.forms)
except KeyError:
form_vars = {}
for k in form_vars:
self.vars[k] = form_vars[k]
process = False
Expand Down

0 comments on commit f20abb3

Please sign in to comment.