What should I worry about Python template engines and web frameworks?

I am a C # and ASP.NET MVC developer. I have finished some console Python applications, but I'm new to using Python for web applications. I read a lot about Python servers and template engines.

But I'm worried about:

  • What template models are suitable for the Python / Python web framework? or should match?
  • Could there be security issues in the template engines? or I can choose anyone who likes the syntax.
  • Can any template engine integrate data (my models, orm models) with the controller and myself? Can this integration cause problems with security, memory?
  • Does it make sense to use Python 2.x or 3.x for any template engine?

I know there is jinja2 , pytenjin (seems very fast), pyrazor . I tried everything and I feel very comfortable with pyRazor because of my ASP.NET MVC background.

and the last questions after my worries:

  • What template mechanisms should I use?
  • What is the best development environment (python web infrastructure, template engine) to start development with Tornado?

I know that I asked a lot of questions, but I must be careful before diving into the development for real projects.

Edit Comments : Well, I feel that I need to be more specific about what I'm looking for. Like many developers need python web programming (at least from other platforms), I need to find out what development options I have. (IDEs, template engines, web servers, etc.) And how to combine them correctly to reduce development time and increase productivity without compromising security.

Update 1: I think that we, developers from the world of VS and ASP.NET, are used to having everything in a box ready for events. When it comes to using another technology due to the needs of the project, we (at least I) get paranoid. Because we need to put everything in harmony. Obviously, for .NET projects IIS, .NET and VS (with all advanced features) are used.

Well, after so many searches and investigations, I decided to use PyCharm as an IDE with Django. I want PyDharm to support web2py as a way to support Django.

OK, what about the server? I will let nginx or cherokee work for me.

OK, what about the template? I will use the default Django template engine (I don't like as much as I like pyRazor). But it will be easier to find help or request an additional function. In later stages, I can try jinja2 again (In PyCharm you can change the template engine to use in Django).

0
source share
1 answer

There is no final template or web frame. For instance. I like the combination of flask , Jinja2 and SQLAlchemy . Others prefer Django , which uses the ORM and template engine. Others prefer mako (also a template engine). Just try them and find out what you like best.

Of course, there may be security issues in your templates, for example. XSS Attacks , but this is unlikely, Jinja2 has, for example, autoescaping is enabled by default, so you can use whatever you want and it will automatically disappear.

Yes, you can integrate your ORM models using template engines (you can pass db-instance and models to the template), but I wouldn’t do this, simply because it’s easier to do on your route. If you integrate it, there will be no more memory and memory problems, as if you had done it in your "normal" code.

The Python version does not matter (as long as the engine supports it), but I would use Python 2.7 because it brings some interesting Python 3 features and has more libraries available (not everything is ported to Python 3 more).

+4
source

Source: https://habr.com/ru/post/1439669/


All Articles