-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is constructor of FlaskView called per number of methods? #114
Comments
I'm not sure why. Maybe you can try to create one instance for all |
@hoatle 1)I edited
The output is below.
2)I installed |
I found one solution for it, when declare the class methods names with prefix of __ then init method is not being called for the method count. ex: class AppRouting(FlaskView):
in above case init method will be called for 3 times. due to 2 methods declared under the class. now change it like below class AppRouting(FlaskView):
now init method will get called only 1 time. But __test1 method can't be accessed in other class as it is declared as private. Unable to find any other resolution other than this. |
I met the same problem. And my solution is still ugly but needn't rename all the methods' names.
The output is like this:
|
The test code to help to try fix the bug that repeating calling constructor (pallets-eco#114). pallets-eco#114
Ignore test code and resources
Any progress on this? Makes it impossible to for example neatly use a getter/setter in the registered class as they'll be called for two different instances of the class. |
When I run the following code in python 3.6.9, The
__init__()
method is called 5 times.Cmdline output is below.
Is this right?
I think the constructor method is called per number of methods.
If possible, I want the constructor to be called only once.
The text was updated successfully, but these errors were encountered: