Revamp avatar service registry API
Review Request #8479 — Created Oct. 20, 2016 and submitted
AvatarServices now require anAvatarSettingsManagerclass when
being instantiated. Previously, this was an optional argument that
defaulted to the defaultAvatarSettingsManagerwhich throws
NotImplementedErrorfor all its methods. However, registries were not
guaranteed to return any third party avatar services instantiated with
the correct settings manager.This has been corrected by making the avatar services registry always
store instances instead. It has simplified the API as now most things
can be done via method calls with theAvatarServiceclass as an
argument instead of itsavatar_service_idattribute. It also has the
benefit of making unit tests more succinct.The
AvatarServicesRegistry'sget_avatar_service,for_user, and
configurable_servicesnethods have been re-written to return an
instance of the requested avatar service, instantiated with the
correct settings manager class.Unit tests & the rest of the avatar services suite have been
re-written in light of these changes.
Ran unit tests.
Tested avatar services still work with Review Board.
| Description | From | Last Updated |
|---|---|---|
|
Actually, wait. Did you update this to bring back has_service for https://reviews.reviewboard.org/r/8480/diff/1-2/ ? |
|
|
|
All the arguments could go on the same line. |
|
|
|
I think the old is_configurable property was nicer API here. |
|
|
|
Mind putting this into an else clause? |
|
|
|
Hm. Do we want to keep a cache of instantiated services? |
|
|
|
We don't use this syntax anywhere else, do we? |
|
|
|
redefinition of unused 'unregister' from line 135 |
|
|
|
redefinition of unused 'unregister' from line 135 |
|
|
|
Can this be falsy but not None? Would it be more correct to do if avatar_service is None? |
|
|
|
These should be absolute class paths. |
|
|
|
Can we add an else clause that asserts that the service is present and enabled? |
|
|
|
Since the else clause returns, how about: if service is None: return None if not self.is_enabled(service): ... ... |
|
|
|
type here and below (sorry!) |
|
|
|
No blank line. |
|
|
|
This can be: configuration = self._settings_manager_class(user).configuration_for( self.avatar_service_id) It fits in the line. |
|
|
|
"subclassed" |
|
|
|
"URLs" |
|
- Description:
-
AvatarServices now require anAvatarSettingsManagerclass whenbeing instantiated. Previously, this was an optional argument that defaulted to the default AvatarSettingsManagerwhich throwsNotImplementedErrorfor all its methods. However, registries were notguaranteed to return any third party avatar services instantiated with the correct settings manager. This has been corrected by making the avatar services registry always
store instances instead. It has simplified the API as now most things can be done via method calls with the AvatarServiceclass as anargument instead of its avatar_service_idattribute. It also has thebenefit of making unit tests more succinct. ~ The
AvatarServicesRegistry'sget_avatar_serviceandfor_user~ methods have been re-written to return an instance of the requested ~ avatar service, instantiated with the correct settings manager class. ~ The
AvatarServicesRegistry'sget_avatar_service,for_user, and~ configurable_servicesnethods have been re-written to return an~ instance of the requested avatar service, instantiated with the + correct settings manager class. ~ Unit tests have been re-written in light of these changes.
~ Unit tests & the rest of the avatar services suite have been
+ re-written in light of these changes. - Testing Done:
-
~ Ran unit tests.
~ Ran unit tests.
+ Tested avatar services still work with Review Board.
-
Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py
-
Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py -
-
Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py -
-
Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py
-
Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py
-
Tool: Pyflakes Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: PEP8 Style Checker Processed Files: djblets/avatars/forms.py djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py
Tool: PEP8 Style Checker Processed Files: djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py Tool: Pyflakes Processed Files: djblets/avatars/settings.py djblets/avatars/tests.py djblets/avatars/registry.py djblets/avatars/services/base.py