--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/552bd3e1-7aa5-40bf-b737-f2db371cdf8an%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/ad3c7823-324e-4bd5-83f1-3ac492832cacn%40googlegroups.com.
I’m very sorry :-( but I think that with this last modification we have returned to what I think is the origin of the problem.
Adding recode_unicode=False brings me back to problems with search_queries in Grid. With non-us-ascii characters there are encoded problems.
Removing the following, Grid works fine but Form doesn’t work fine.
line 126 py4web/core.py
FormsDict.recode_unicode = False
Removing this too, Form works fine but Grid doesn’t.
lineas 122, 123, 124, 125 de py4web/core.py
# monkey patching bottle/ombott
request.query.__class__.get, request.query.__class__.getraw = (
request.query.__class__.getunicode,
request.query.__class__.get,
)
If Grid works Form does not work well or vice versa.
Here is an example that is not working well with the latest modifications.
from py4web import action, request, abort, redirect, URL, Field
from .common import db, session
from py4web.utils.grid import Grid
db.define_table(
't_test_grid',
Field('f_test1', 'string', length=30),
)
db.commit()
if not db(db.t_test_grid).select():
db.t_test_grid.insert(f_test1='niña')
db.t_test_grid.insert(f_test1='niño')
db.t_test_grid.insert(f_test1='camión')
db.t_test_grid.insert(f_test1='cigüeña')
db.commit()
@action('grid_test')
@action('grid_test/<path:path>')
@action.uses('grid_test.html', db)
def grid_test(path=None):
t_test_grid = db.t_test_grid
grid = Grid(
path=path,
query=t_test_grid,
search_queries=[
('Test', lambda value: t_test_grid.f_test1.contains(value)),
],
rows_per_page=10,
)
return dict(grid=grid)
I don’t know if it is well understood.
I think the problem with Form started with this thread : https://groups.google.com/g/py4web/c/fuI6I_7LbSk/m/AZYm7kmqAAAJ
Carlos.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/236efb0e-07c0-4935-bcc5-72a5546f5cf5n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/0469fb85-2833-47b3-a5cd-49cd0e3847bcn%40googlegroups.com.
Here is a quick example to reproduce the problem.
Currently Form works fine and the search in Grid does not work well.
controllers.py
from py4web import action, request, abort, redirect, URL, Field
from py4web.utils.form import Form
from py4web.utils.grid import Grid
from yatl.helpers import A
from .common import db, session
db.define_table(
't_test_grid',
Field('f_test1', 'string', length=30),
)
db.define_table(
't_test_form',
Field('f_test1', 'text', default=''),
)
if not db(db.t_test_grid).select():
db.t_test_grid.insert(f_test1='niña')
db.t_test_grid.insert(f_test1='niño')
db.t_test_grid.insert(f_test1='camión')
db.t_test_grid.insert(f_test1='cigüeña')
db.commit()
@action('grid_test')
@action('grid_test/<path:path>')
@action.uses('test.html', db)
def grid_test(path=None):
t_test_grid = db.t_test_grid
grid = Grid(
path=path,
query=t_test_grid,
search_queries=[
('Test', lambda value: t_test_grid.f_test1.contains(value)),
],
rows_per_page=10,
)
return dict(stuff=grid, link=A('form', _href=URL('form_test')))
@action('form_test', method=['GET', 'POST'])
@action.uses('test.html', db)
def form_test():
t_test_form = db.t_test_form
if not db(t_test_form).select():
t_test_form.insert(f_test1='áéíóú ñÑ Üü')
record = db(
t_test_form
).select().last()
form = Form(t_test_form, record)
if form.accepted:
redirect(URL('form_test'))
return dict(stuff=form, link=A('grid', _href=URL('grid_test')))
test.html
[[extend 'layout.html']]
[[=link]]
[[=stuff]]
Carlos
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/28a86c40-90c4-4f58-b5c1-0962fb748784n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/937793b9-110c-48cf-bcb0-3675f6048243n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/65b91715-cd59-4a5e-8245-11d577920155n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/8f46f680-3e50-4a28-90df-97d6f59ddcfen%40googlegroups.com.