-
Notifications
You must be signed in to change notification settings - Fork 6
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
request MUST be declared for serializer #3
base: master
Are you sure you want to change the base?
Conversation
does anybody care about pull requests? |
Hi @theromis, I apologise for the monumental delay. And thanks for contributing! Apart from being busy at work I've been putting off a few housekeeping tasks on this project such as tests and PyPI packaging for way too long, which is why I have not been able to focus on your PR until now. I have a couple of minor questions regarding your changes, I'll add them in the code. Also, If you like to elaborate a little on the use case for this that would be greatly appreciated as it's not 100% clear to me at this moment. |
) | ||
|
||
if self.uri_prefix: | ||
return request.build_absolute_uri(self.uri_prefix + image.url) |
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.
Is uri_prefix
(and settings.URI_PREFIX
) meant to for a path component or a complete URL, or both? I guess build_absolute_uri()
would handle both.
I think I would prefer something like
from urllib.parse import urljoin
urljoin(self.uri_prefix, image.url)
or even os.path.join(self.uri_prefix, image.url)
though.
except AttributeError: # NOQA | ||
return super(HyperlinkedSorlImageField, self).to_native(image.url) # NOQA | ||
request = self.context.get('request', None) | ||
assert request is not None, ( |
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.
Not sure how this would fare with existing usage as the current implementation attempts to use FileField.to_representation()
behaviour (i.e. relative path to image) as a fallback. Up until now I've let to_representation()
fail silently (which admittedly is not always the best option) but this introduces a potential AssertionError
.
While I'm not too afraid of breaking changes at this stage I think it's worth some consideration. Perhaps this behaviour should only be triggered by a specific option?
@@ -65,6 +66,7 @@ def __init__(self, geometry_string, options={}, *args, **kwargs): | |||
""" # NOQA | |||
self.geometry_string = geometry_string | |||
self.options = options | |||
self.uri_prefix = uri_prefix |
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.
A corresponding entry in the Args:
list above would be nice
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.
you mean you don't like settings usage here?
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.
Sorry that's a bit unclear now that I read it myself. I just meant I'd like an the docstring above, under the Args heading.
but what we will gonna do with this stuff? what do you think about the rest of this PR? |
Copying some of the thoughts from #5 (comment), I think you could sum up my thoughts at the moment with: As I mentioned here In large part I don't really understand why The same goes for Also, tests are failing and should probably be fixed before merging :) |
I will remove You think having |
No description provided.