Well, to be honest, it's not a question about Pyramid, it's a question
about an absolutely basic pattern in web programming. I was doing that with
Perl CGI scripts 25 years ago, when Python was still in infancy, and
Pyramid didn't exist.

The problem is actually very simple : you use *one* view, not two, i.e. the
form must call its own URL (e.g. action="#")

The view tests if a non-null parameter "cpf" had been provided. If that's
the case, you compute the results (SQL query), and you send the two values
to the template (cpf, and the rows).

The template tests if it receives a "cpf" parameter. If so, it auto-fills
the form, and displays the rows (using a combination of {%if ...}, {%for
...} etc. as appropriate).

Again, it's not a Pyramid question, or a Pyramid solution, I would have
given you exactly the same answer with FastAPI, PHP, Rails, Flask, etc.

Le jeu. 23 nov. 2023 à 20:50, Oberdan Santos <sc.ober...@gmail.com> a
écrit :

> You should note in the subject statement that in addition to the query, I
> have the problem of the result being published on another page.
> query page code
> # templates/pac_recepx.jinja2
>
> <div class="form">
>         <div class="row g-2 mt-3">
>             <h3><span class="font-semi-bold">Consultar cadastro do
> paciente</span></h3>
>         </div>
>         <form class="form-inline my-2 my-lg-0" action="
> http://localhost:6543/queryx"; method="GET">
>             <label for="cpf">Digite o CPF (11 números)</label>
>             <input class="form-control mr-sm-2" type="text" id="cpf"
> name="cpf" required maxlength="11" value=''>
>             <button class="btn btn-outline-success my-2 my-sm-0"
> type="submit">Consultar</button>
>         </form>
>     </div>
>
> The result is going to...
> action="http://localhost:6543/queryx
>
> How do I take this result to the same page as the query
> (templates/pac_recepx.jinja2), that is, place it below the query?
>
> Thank you in advance for your support.
>
> Oberdan Costa
>
> Em quinta-feira, 23 de novembro de 2023 às 16:19:16 UTC-3, Laurent Daverio
> escreveu:
>
>> Hi Mike,
>>
>> .filter() and .filter_by() are still both valid in SQLAlchemy 2.x. I
>> think .filter() is a synonym of .where().
>>
>> Note : what is deprecated, but still available, is the "query syntax". I
>> even think it's no longer documented. Recommended syntaxes are here:
>>
>>
>> https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-orm-usage
>>
>> It's a bit more verbose, but closer to SQL :)
>>
>> Laurent.
>>
>> Le jeu. 23 nov. 2023 à 20:08, Mike Orr <slugg...@gmail.com> a écrit :
>>
>>> On Thu, Nov 23, 2023 at 7:03 AM Oberdan Santos <sc.ob...@gmail.com>
>>> wrote:
>>> > O codigo no formato acima não executou, apresentou erro, mas foi de
>>> grande valia,  muito obrigado). Fiz uma pequena alteração e deu certo.
>>> > Funcionou assim:
>>> > cpf = request.params["cpf"]
>>> >    rows =
>>> request.dbsession.query(Paciente).filter(Paciente.cpf==cpf).all()
>>>
>>> I remembered that after I wrote the comment, that it's
>>> `filtey(Paciente.cpf==cpf)` and `filter_by(cpf=cpf)`. And `filter_by'
>>> may not be supported in SQLAlchemy 2.0? I'm still on 1.4/1.3.
>>>
>>> I'm afraid I don't know enough Portuguese to understand the rest of the
>>> message.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to pylons-discus...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3DupAGsreB_H48SxC0_5fRctbdKSxs7kn1dcOrfZRaycJbw%40mail.gmail.com
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/b800223f-dcb3-4a1a-9cd3-ef8c74255b6dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/b800223f-dcb3-4a1a-9cd3-ef8c74255b6dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6zhNwdSpUgDJKDxiwa1Ri1b5HPg1XG-UHjo1M%3DTZtrogg%40mail.gmail.com.

Reply via email to