-
Notifications
You must be signed in to change notification settings - Fork 85
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
Allow setting and resetting the global adaptation manager. #145
Conversation
The global adaptation manager is used by traits for automatic adaptation. Setting and resetting it is useful at application start-up, but especially during testing to reset the global state.
Can one of the admins verify this patch? |
#: PROVIDED FOR BACKWARD COMPATIBILITY ONLY, IT SHOULD NEVER BE USED DIRECTLY. | ||
#: If you must use a global adaptation manager, use the functions | ||
#: `get_global_adaptation_manager`, `reset_global_adaptation_manager`, | ||
#: `set_global_adaptation_manager`. | ||
adaptation_manager = AdaptationManager() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wrap access to this attribute and throw a deprecation warning, or is it an overkill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just complicated to do: you need to wrap the module in an object... I'd say it's overkill.
adaptation_manager
is not exposed through the api
modules, so you need to really look for it in order to get it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough
I broke something, looking into it. |
Fixed, and updates CHANGES and docs. |
function | ||
:func:`~traits.adaptation.adaptation_manager.get_global_adaptation_manager`. | ||
The traits automatic adaptation features also use the global manager. | ||
Having a global adaptation manager can get you into troubles, for the usual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
troubles
-> trouble
👍 |
adaptation_manager.register_factory( | ||
factory = ex.UKStandardToEUStandard, | ||
from_protocol = ex.UKStandard, | ||
to_protocol = ex.EUStandard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be very fussy to request an extra comma here? If so, I won't.
LGTM; I've left some comments, but I'm happy for this to be merged as it is. |
@mdickinson I fixed the details, but if it's of with you I'd like to leave the rest unchanged. |
Sure. I'll wait for the CI and then merge. |
Allow setting and resetting the global adaptation manager.
The global adaptation manager is used by traits for automatic
adaptation. Setting and resetting it is useful at application
start-up, but especially during testing to reset the global
state.