Flask project functools_wraps why you want to use a decorator?

  1. Why you want to use in the project

That project user_login_data in why to use it?

Now we begin to analyze:

For example, maybe we all view function method, add a route:

If you add that route, it will be a problem, because a view function can not be decorated in two different routes

as follows:

A route that corresponds to a function.

What if we give before this decorator masked: as follows:

There are two places to user_login_data decorator:

run:

Hey, we found no error. This is maybe because the function is in a different blueprint, is the name of the function name with a blueprint.

Another way to add that if I give news blueprint:

Then run:

Error was found, the error message: view functions mapping to override an existing method news.wrapper

In fact, plainly, is to first add routes / comment / pair news.wrapper method <int: news_id> then add nwes.wrapper method for routing / <int: news_id>

to sum up:

Guess you like

Origin blog.csdn.net/weixin_44786530/article/details/91458369