Update AvatarService docs and guide to include required fields and methods
Review Request #9493 — Created Jan. 19, 2018 and submitted
When an extension for AvatarServices doesn't include an implementation for
get_avatar_urls_uncached
orget_etag_data
, it throws a 500 error. With the changes, we now return a defaultetag_data
and return an empty string for the uncached avatar urls in addition to logging an error.
ran
make html
and the formatting changes appear.tests for AvatarServices passed. Added 2 unit tests to ensure
get_avatar_urls_uncached
logs an error andget_etag_data
returns the default[avatar.service_id, user.pk]
Description | From | Last Updated |
---|---|---|
Hey Florie - did you try generating the sourcecode for the avatars to make sure that it's properly formatted? If … |
mike_conley | |
The Bugs field needs to be filled in with the bugs this references. |
chipx86 | |
The documentation is great, but I think part of the original problem in the report is that the user saw … |
chipx86 | |
The description/testing need additional work to meet our standards. We have a guide on what we expect from these fields: … |
chipx86 | |
Can you update the summary to indicate this is a docs change? Something like: Update AvatarService docs and guide to … |
brennie | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
There needs to be a blank line separating the list and the text preceding it. |
chipx86 | |
No "and" at the end here. For lists of items in docs, you don't treat each item as part of … |
chipx86 | |
No need for "attributes". |
chipx86 | |
Given the above, you'd want to rewrite this as well. |
chipx86 | |
No need for "method". There needs to be a blank line separating the list and the text preceding it. |
chipx86 | |
This should go before the django imports. We put imports into three groups: from __future__ import unicode_literals #always first import … |
brennie | |
Missing a period. Should mention that they should override get_etag_data for caching. |
brennie | |
Undo this change. We want this to raise an error. |
brennie | |
Can you also change this into a definition list? |
brennie | |
This should use a definition list: Subclasses must also override: :py:meth:`~base.AvatarService.get_avatar_urls_uncached`: This method computes and returns the avatar URLs for … |
brennie |
- Change Summary:
-
Fixing lint issues
- Commit:
-
b8973c8e62b42144274bc03d77b655857cc157223e71986c3209801cec035c692487c7d276f752dd
- Diff:
-
Revision 2 (+9 -3)
- Commit:
-
3e71986c3209801cec035c692487c7d276f752ddf0d7d46604b29ac895d99dad3da2e5563dc09abd
- Diff:
-
Revision 3 (+7 -3)
Checks run (2 succeeded)
-
-
Hey Florie - did you try generating the sourcecode for the avatars to make sure that it's properly formatted? If so, you should add that to Testing Done. If not, I suggest doing that.
I think you can do that from within the
djblets/docs/djblets
directory, and runningmake html
. You might have to install some packages (likesphinx
).
- Testing Done:
-
~ Doc changes so it's now required. Will still have the same error.
~ ran
make html
and the formatting changes appear. - Commit:
-
f0d7d46604b29ac895d99dad3da2e5563dc09abdbad8b3e9309392e081c31cb4e15f46e7cb10fdc5
Checks run (2 succeeded)
-
-
-
The documentation is great, but I think part of the original problem in the report is that the user saw a crash and didn't know what caused it immediately. So, along with the documentation improvements, we should make sure things do not crash, but rather that raised exceptions are logged.
One place to do this is in
djblets/avatars/base.py
, whereget_avatar_urls_uncached
is called. We should catch the exception, log the error, and return a sane result (like{}
).The other function,
get_etag_data
is actually not called in Djblets. We probably should not be raisingNotImplementedError
here, since we can provide a sane default. So, I'd recommend altering the function to return a sane default, like:return [self.avatar_service_id, user.pk]
This would probably be an okay default, and would prevent blowing up.
Unit tests need to be added to:
- Test calling
get_avatar_urls
withoutget_avatar_urls_uncached
having an implementation, and ensuring that we get a sane result back and that data is logged (you'll use kgb for this -- ask David or Barret about how to do this). - Test that
get_etag_data
returns that default value.
- Test calling
-
The description/testing need additional work to meet our standards. We have a guide on what we expect from these fields: https://www.reviewboard.org/docs/codebase/dev/writing-good-descriptions/
-
-
No "and" at the end here. For lists of items in docs, you don't treat each item as part of a sentence.
-
-
-
- Description:
-
~ Adding required fields to AvatarService get_etag_data and get_avatar_urls_uncached
~ When an extension for AvatarServices doesn't include an implementation for
get_avatar_urls_uncached
orget_etag_data
, it throws a 500 error. With the changes, we now return a defaultetag_data
and return an empty string for the uncached avatar urls in addition to logging an error. - Testing Done:
-
ran
make html
and the formatting changes appear.+ + tests for AvatarServices passed. Added 2 unit tests to ensure
get_avatar_urls_uncached
logs an error andget_etag_data
returns the default[avatar.service_id, user.pk]
- Bugs:
-
- Commit:
bad8b3e9309392e081c31cb4e15f46e7cb10fdc5add8c6a0211be38d13d67fe82b1f7f0232cccee7- Diff:
Revision 5 (+36 -16)
Checks run (2 succeeded)
flake8 passed.JSHint passed.
-
-
This should go before the django imports.
We put imports into three groups:
from __future__ import unicode_literals #always first import logging # Python standard library import os from django.conf import foo # 3-rd Party imports from djblets.foo import bar # Project imports
-
-
-
-
This should use a definition list:
Subclasses must also override: :py:meth:`~base.AvatarService.get_avatar_urls_uncached`: This method computes and returns the avatar URLs for the given user at a requested size at different resolutions :py:meth:`~base.AvatarService.get_etag_data`: This method returns a list of unicode strings that uniquely identify the avatar services and its configuration.
We should mention
get_etag_data
has a default impl but it should probably be overriden to include appropriate setting values for caching.