Obrigado!!!!

Em quinta-feira, 16 de novembro de 2023 às 18:43:03 UTC-3, Steve Piercy 
escreveu:

> This page has some resources.
>
> https://trypyramid.com/documentation.html
>
> --steve
>
>
> On 11/16/23 1:37 PM, Oberdan Santos wrote:
>
> I have done a lot of reading, some of it with tutorials, but very 
> superficial.
> I have some scripts with a database without using http transactions, which 
> work normally.
> Any suggestions for someone who could be helping me debug the code or even 
> yourself and how I can pay for it?
>
> Anyway, thanks for the support.
>
>
> Em quinta-feira, 16 de novembro de 2023 às 18:24:43 UTC-3, Oberdan Santos 
> escreveu:
>
>> Sim!!  importante dica.
>>
>> Em quinta-feira, 16 de novembro de 2023 às 18:19:06 UTC-3, Laurent 
>> Daverio escreveu:
>>
>>> Yes, that's true. If you write a monolithic app with Jinja templates, 
>>> you will use {{ }}. If you use a Javascript frontend, you will find that 
>>> `${}` is very convenient :)
>>>
>>> Le jeu. 16 nov. 2023 à 21:52, Florian Schulze <[email protected]> 
>>> a écrit :
>>>
>>>> With Jinja Templates you have to use {{ save_url }} not ${save_url}. 
>>>> You can see from the URL the form is trying to POST to that it contains 
>>>> the 
>>>> $ sign. You can also see such things from your Browser HTML Inspector.
>>>>
>>>> Regards, 
>>>> Florian Schulze
>>>>
>>>> On 16 Nov 2023, at 14:51, Oberdan Santos wrote:
>>>>
>>>> Hello!! I am facing a problem when trying to post data to the database. 
>>>> When asking to send the application data I receive the following: Squashed 
>>>> pyramid.httpexceptions.HTTPNotFound at 
>>>> http://localhost:6543/mod_plataforma/mod1_plataforma/recepx/$%7Bsave_url%7D
>>>>
>>>> . Below is information about my files.
>>>>
>>>> # piprdc/piprdc/routes.py
>>>> def includeme(config):
>>>>      config.add_static_view('static', 'static', cache_max_age=3600)
>>>>      config.add_route('home', '/')
>>>>      config.add_route('modulo_x', '/mod_plataforma')
>>>>      config.add_route('modulo1', '/mod_plataforma/mod1_plataforma')
>>>>      config.add_route('modulo2', '/mod_plataforma/mod2_plataforma')
>>>>      config.add_route('modulo3', '/mod_plataforma/mod3_plataforma')
>>>>      config.add_route('modulo4', '/mod_plataforma/mod4_plataforma')
>>>>      config.add_route('modulo5', '/mod_plataforma/mod5_plataforma')
>>>>      config.add_route('modulo6', '/mod_plataforma/mod6_plataforma')
>>>>      config.add_route('abcx', '/mod_plataforma/mod1_plataforma/recepx')
>>>>      config.add_route('add_reg', 
>>>> '/mod_plataforma/mod1_plataforma/recepx/add_reg')
>>>>      config.add_route('query', 
>>>> '/mod_plataforma/mod1_plataforma/recepx/query')
>>>>
>>>> ..............................
>>>>
>>>> #views/default.py
>>>> from pyramid.view import view_config
>>>> from pyramid.response import Response
>>>> from sqlalchemy.exc import SQLAlchemyError, DBAPIError
>>>> from pyramid.httpexceptions import HTTPFound
>>>> from .. import models
>>>> from ..models import Patient
>>>> from ..models import get_tm_session
>>>> dbsession = get_tm_session
>>>>
>>>> view_config(route_name='add_reg', 
>>>> renderer='piprdc:templates/reg_pacx.jinja2')
>>>> def add_reg(request):
>>>>      save_url = request.route_url('add_reg')
>>>>      request.route_url('query')
>>>>      print('RUN')
>>>>      if request.params:
>>>>          id=request.params['id']
>>>>          name=request.params['name']
>>>>          age=request.params['age']
>>>>          birth_date=request.params['birth_date']
>>>>          sex=request.params['sex']
>>>>          race=request.params['race']
>>>>          fone=request.params['fone']
>>>>          address=request.params['address']
>>>>          cpf=request.params['cpf']
>>>>          cns=request.params['cns']
>>>>          patients=Patient(id=id, name=name, age=age, 
>>>> date_birth=date_birth, sex=sex,
>>>>                             race=race, phone=phone, address=address, 
>>>> cpf=cpf, cns=cns)
>>>>          try:
>>>>              dbsession.add_reg(patients)
>>>>              return HTTPFound(location=request.route_url('query'))
>>>>          except DBAPIError:
>>>>              return Response("DB ERROR")
>>>>      else:
>>>>          print('DO NOT RUN')
>>>>          return{'save_url': save_url, 'project': 'piprdc'}
>>>>
>>>> ........................................
>>>>
>>>> #templates/reg_pacx.jinja2
>>>> {% extends "basefull.jinja2" %}
>>>> {% block container %}
>>>> <html>
>>>> <body>
>>>>     <h1><span class="font-semi-bold">Patient registration</span></h1>
>>>>     <form action="${save_url}" method="POST">
>>>>     <p>Patient Id: <input type="Integer" name="id"/> </p>
>>>>     <p>Patient Name: <input type="text" name="name"/> </p>
>>>>     <p>Age: <input type="Integer" name="age"/> </p>
>>>>     <p>Date of birth: <input type="Integer" name="date_birth"/> </p>
>>>>     <p>Gender: <input type="text" name="sex"/> </p>
>>>>     <p>Race: <input type="text" name="breed"/> </p>
>>>>     <p>Phone: <input type="text" name="phone"/> </p>
>>>>     <p>Address: <input type="text" name="address"/> </p>
>>>>     <p>CPF: <input type="Integer" name="cpf"/> </p>
>>>>     <p>CNS: <input type="Integer" name="cns"/> </p>
>>>>     <p><input type="submit" value="Submit"> </p>
>>>> </body>
>>>> </html>
>>>> {% endblock container %}
>>>>
>>>> ................................
>>>> #models/__init__.py
>>>>
>>>> from sqlalchemy import engine_from_config
>>>> from sqlalchemy.orm import sessionmaker
>>>> from sqlalchemy.orm import configure_mappers
>>>> from sqlalchemy_continuum.plugins import Plugin
>>>> import zope.sqlalchemy
>>>>
>>>> from .mymodel import Patient # flake8: noqa
>>>>
>>>> configure_mappers()
>>>>
>>>> def get_engine(settings, prefix='sqlalchemy.'):
>>>>      return engine_from_config(settings, prefix)
>>>>
>>>> def get_session_factory(engine):
>>>>      factory = sessionmaker()
>>>>      factory.configure(bind=engine)
>>>>      return factory
>>>>
>>>> def get_tm_session(session_factory, transaction_manager, request=None):
>>>> dbsession = session_factory(info={"request": request})
>>>>      zope.sqlalchemy.register(
>>>>          dbsession, transaction_manager=transaction_manager
>>>>      )
>>>>      return dbsession
>>>> def includeme(config):
>>>>    
>>>>      settings = config.get_settings()
>>>>      settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
>>>>    
>>>>       config.include('pyramid_tm')
>>>>
>>>>      config.include('pyramid_retry')
>>>>
>>>>      # hook to share the dbengine fixture in testing
>>>>      dbengine = settings.get('dbengine')
>>>>      if not dbengine:
>>>>          dbengine = get_engine(settings)
>>>>
>>>>      session_factory = get_session_factory(dbengine)
>>>>      config.registry['dbsession_factory'] = session_factory
>>>>    
>>>>      def dbsession(request):
>>>>          dbsession = request.environ.get('app.dbsession')
>>>>          if dbsession is None:
>>>>               dbsession = get_tm_session(
>>>>                  session_factory, request.tm, request=request
>>>>       config.add_request_method(dbsession, reify=True)
>>>>
>>>> Any help is welcome.
>>>> --
>>>> 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 [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pylons-discuss/6c951fdb-95ea-440f-b3f7-81f93845dacfn%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/pylons-discuss/6c951fdb-95ea-440f-b3f7-81f93845dacfn%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 [email protected].
>>>>
>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pylons-discuss/CF08852E-F452-4544-A4B1-F91630CDBA51%40florian-schulze.net
>>>>  
>>>> <https://groups.google.com/d/msgid/pylons-discuss/CF08852E-F452-4544-A4B1-F91630CDBA51%40florian-schulze.net?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 [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pylons-discuss/d1428c3b-9447-428f-b9e4-1c808f2c83b2n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/pylons-discuss/d1428c3b-9447-428f-b9e4-1c808f2c83b2n%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/f9bb8e5f-c967-4eaa-988f-ff90358e2ee6n%40googlegroups.com.

Reply via email to