TomatoesBurner / Agile-Web-Community-Forum

0 stars 0 forks source link

Enhancing Development Efficiency with Flask's make_shell_context() #28

Open WannianMEI opened 1 month ago

WannianMEI commented 1 month ago

In Learning Flask, "The function make_shell_context() defined in a Flask application using the @app.shell_context_processor decorator is used to customise the context in a shell session. This approach is very useful, especially if you need to interact frequently with various components of your Flask application during development" Does our group need to add this code? @app.shell_context_processor def make_shell_context(): return {'sa': sa, 'so': so, 'db': db, 'User': User, 'Post': Post, 'Message': Message, 'Notification': Notification}

TomatoesBurner commented 1 month ago

This approach is ideal for the development phase, but is not usually used in production environments. This is an extremely useful feature if you need to interact with models or databases frequently during development.

In production environments, it is a much more common and stable practice to explicitly import required modules and objects directly into the code.1. Clarity and Maintainability In production code, by explicitly importing required libraries and objects at the top of the file, you can quickly see what external modules this file depends on. This clarity helps other developers (or you in the future) understand the structure and functionality of the code, which makes it easier to maintain and extend.

If you want to develop quickly locally, try adding this code to run.py, but don't commit 'commit' and 'push' to the branch. Even though we're students, we try to stick to the real industry standards.

akikodesu commented 1 month ago

This approach is ideal for the development phase, but is not usually used in production environments. This is an extremely useful feature if you need to interact with models or databases frequently during development.

In production environments, it is a much more common and stable practice to explicitly import required modules and objects directly into the code.1. Clarity and Maintainability In production code, by explicitly importing required libraries and objects at the top of the file, you can quickly see what external modules this file depends on. This clarity helps other developers (or you in the future) understand the structure and functionality of the code, which makes it easier to maintain and extend.

If you want to develop quickly locally, try adding this code to run.py, but don't commit 'commit' and 'push' to the branch. Even though we're students, we try to stick to the real industry standards.

So what you're saying is that we should submit code that doesn't use this, right?

TomatoesBurner commented 1 month ago

This approach is ideal for the development phase, but is not usually used in production environments. This is an extremely useful feature if you need to interact with models or databases frequently during development. In production environments, it is a much more common and stable practice to explicitly import required modules and objects directly into the code.1. Clarity and Maintainability In production code, by explicitly importing required libraries and objects at the top of the file, you can quickly see what external modules this file depends on. This clarity helps other developers (or you in the future) understand the structure and functionality of the code, which makes it easier to maintain and extend. If you want to develop quickly locally, try adding this code to run.py, but don't commit 'commit' and 'push' to the branch. Even though we're students, we try to stick to the real industry standards.

So what you're saying is that we should submit code that doesn't use this, right?

YES!

WannianMEI commented 1 month ago

This approach is ideal for the development phase, but is not usually used in production environments. This is an extremely useful feature if you need to interact with models or databases frequently during development. In production environments, it is a much more common and stable practice to explicitly import required modules and objects directly into the code.1. Clarity and Maintainability In production code, by explicitly importing required libraries and objects at the top of the file, you can quickly see what external modules this file depends on. This clarity helps other developers (or you in the future) understand the structure and functionality of the code, which makes it easier to maintain and extend. If you want to develop quickly locally, try adding this code to run.py, but don't commit 'commit' and 'push' to the branch. Even though we're students, we try to stick to the real industry standards.

So what you're saying is that we should submit code that doesn't use this, right?

YES!

I get it.