Closed jdotjdot closed 7 years ago
@jdotjdot Thanks for finding out and opening this PR!
Shouldn't we maybe also initialize also parameter template_name
in Origin
's constructor? Fixing the None
value for one parameter and ignoring the same issue for another one feels like begging for another bugfix. Though I must admit I don't know about any consequences of this (if there are any outside of the Origin
class).
You can add the following at the end of the criticized line 47 to silence the PyLint warning:
# pylint: disable=unused-argument
I think this is safe to do in this one-line function. We won't miss any potential problems.
Can we add a test for this very problem? The current tests also passed before, so we'd need a new one to cover the problem domain. It should fail without your changes. Can you think of one?
I added the template_name
to Origin
and the pylint line. The test I'm a little uncertain of, though, and the reason is that I'm not sure that providing the loader is actually required. As you said, I don't know what the consequences would be, and django-apptemplates
did work fine in general without it—it was only with django-compressor
specifically that I ran into trouble.
The test I'm a little uncertain of, though, and the reason is that I'm not sure that providing the loader is actually required. As you said, I don't know what the consequences would be, and
django-apptemplates
did work fine in general without it
Maybe I was not clear enough:
django-compressor
.Think of that: Your fix has been tested with django-compressor
The tests we have in this repository, on the other hand, all passed even before you added your changes! So, what we'd need to do really is:
django-compressor
that makes our tests fail (obviously only with Django 1.9+) without your changes(As for the "consequences" I intended the additional change of setting also the template_name
parameter.)
I don't use django-compressor but observe this when using django-redis. This PR in its current form fixes it.
@bronger I appreciate your observations. They are valuable input.
@jdotjdot Do you want to address the comments I have made on your PR?
For the tests it's important to prove that the current situation makes them fail, and the changes of this PR make them pass. Then we have certainty. Ideally, we prove that this PR fixes compatibility with both django-redis
and django-compressor
.
Hi @jdotjdot,
is this PR still relevant?
Would you be interested in taking this forward, the final steps?
Fixed via 21c15824a08fd28ea588b4a32b2ca724de0be198. Thanks @jdotjdot!
Thanks for merging!
Sorry it took so long! Well, we have no tests for the issue now, really. Let's cross our fingers.
I had to redo the changes due to a conflict after merging the other PR, that's why your name isn't in the commits, I apologize, but I put it into the README. Hope that's fine.
It's totally fine; I don't care at all.
On Sun, Jul 9, 2017 at 5:38 PM, Peter Bittner notifications@github.com wrote:
Sorry it took so long! Well, we have no tests for the issue now, really. Let's cross our fingers.
I had to redo the changes due to a conflict after merging the other PR, that's why your name isn't in the commits, I apologize, but I put it into the README. Hope that's fine.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bittner/django-apptemplates/pull/1#issuecomment-313965491, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRHQRjBPVkGL7IHfoeW99W0nTSkSATwks5sMUhQgaJpZM4Iqzin .
This is for compatibility with Django 1.9 + Django Compressor.
I found that running
python manage.py compress
was throwing an error:The issue was due to the fact that Django compressor calls
origin.loader.get_contents(...)
, but theOrigin
instances being returned by the apptemplates loader didn't bind the loader to theOrigin
. This fixes that.All of the tests passed. I am not sure if Django Compressor is the only use case for this, but it wouldn't surprise me if there were others, since Django's loaders now seem to bind the loader to the
Origin
.Update: The only tests that fails is a pylint one because one of the arguments is unused in the <Django1.9 compatibility version of the function definition. I think this is how it should be but don't know how to silence pylint here. Or, if you'd prefer I find a way to somehow use the extra argument, let me know what your stylistic preference is.