-
Notifications
You must be signed in to change notification settings - Fork 105
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
Default Box fails to handle singleton instances of itself #210
Comments
I spent some time to look into this more, and there are just some nuances that need addressed to get it working.
Just changing that will still result in (Not tested in depth but working for simple examples) from box import Box
_test_box = None
class TestBox(Box):
def __new__(cls, *args, **kwargs):
global _test_box
if _test_box is None:
kwargs['default_box'] = True
kwargs['default_box_attr'] = Box
kwargs['box_class'] = Box
_test_box = super().__new__(cls, *args, **kwargs)
return _test_box
def __init__(self, *args, **kwargs):
kwargs['default_box'] = True
kwargs['default_box_attr'] = Box
kwargs['box_class'] = Box
super().__init__(*args, **kwargs)
self.test_method()
def test_method(self):
_this_should_not_fail = self.env I think this is good to document on the wiki as it did take a bit to fully understand it. Will keep this open until that documenting is complete |
It appears that trying to use Default Box in a singleton pattern breaks it. See below for code and traceback
Traceback is as follows
Environment Details
The text was updated successfully, but these errors were encountered: