Skip to content

Port to Django 1.6 #1769

Closed
wants to merge 1 commit into from

3 participants

@washort
washort commented Feb 15, 2014

These are the last few changes needed for Django 1.6 compatibility.
PRs for dependencies:
jbalogh/test-utils#25
mozilla/nuggets#4

@diox diox and 1 other commented on an outdated diff Feb 15, 2014
requirements/prod.txt
dj-database-url==0.2.2
django-aesfield==0.1.2
django-browserid==0.8
-django-cache-machine==0.8
@diox
diox added a note Feb 15, 2014

For every requirement you had to fork, we need to push for a new release with your fixes. Let's try to avoid keeping forks around.

@washort
washort added a note Feb 15, 2014

links for dependency PRs added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox
diox commented Feb 15, 2014

So, I realize this is going to be annoying, but I think we need to split this PR up. I'd like to have at least the version-related changes and the fixtures changes in separate PRs to make it easier to review and spot regressions.

The most backwards-compatible changes we can merge before the actual switch to 1.6, the better.

@washort
washort commented Feb 15, 2014

I agree that splitting things up is better. I'll see what I can do.

@washort
washort commented Feb 18, 2014

preliminary changes moved to mozilla/zamboni#1774

@washort
washort commented Feb 18, 2014

preliminary changes merged.

@diox diox and 1 other commented on an outdated diff Feb 24, 2014
apps/addons/tests/test_models.py
@@ -2199,6 +2199,7 @@ def setUp(self):
def test_extract(self):
File.objects.create(platform=self.platform_mob, version=self.version,
filename=self.xpi_path('langpack-localepicker'))
+ self.addon.update(_current_version=self.version)
@diox
diox added a note Feb 24, 2014

This shouldn't be necessary with the removal of the version magic, or something is wrong.

@washort
washort added a note Feb 24, 2014

Something must be wrong then, because removing this causes get_localepicker to fail.

@diox
diox added a note Feb 25, 2014

Even if you self.addon.reload() ?

Edit:* It could be because the File we create has the wrong status actually.

@washort
washort added a note Feb 25, 2014

reload() works here without that update. Oops, no it doesn't. I'll have a look at the file status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on an outdated diff Feb 24, 2014
apps/addons/tests/test_models.py
@@ -2213,6 +2214,7 @@ def test_extract_no_files(self):
def test_extract_not_language_pack(self):
File.objects.create(platform=self.platform_mob, version=self.version,
filename=self.xpi_path('langpack-localepicker'))
+ self.addon.update(_current_version=self.version)
@diox
diox added a note Feb 24, 2014

See above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on an outdated diff Feb 24, 2014
apps/api/tests/test_views.py
@@ -1283,6 +1283,7 @@ def setup_localepicker(self, platform):
self.addon.update(type=amo.ADDON_LPAPP, status=amo.STATUS_PUBLIC)
version = self.addon.versions.all()[0]
File.objects.create(version=version, platform_id=platform)
+ self.addon.update(_current_version=version)
@diox
diox added a note Feb 24, 2014

Again shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox and 1 other commented on an outdated diff Feb 24, 2014
apps/users/models.py
@@ -312,7 +312,9 @@ def last_login(self):
@amo.cached_property
def reviews(self):
"""All reviews that are not dev replies."""
- return self._reviews_all.filter(reply_to=None)
+ qs = self._reviews_all.filter(reply_to=None)
+ list(qs) # This line is magic. Delete it.
@diox
diox added a note Feb 24, 2014

wat ?

@washort
washort added a note Feb 24, 2014

I should try deleting that now, yeah :)

@washort
washort added a note Feb 25, 2014

absence of this line causes several reviews tests to hang. I'll add a more informative comment and we can tackle the source of it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on an outdated diff Feb 24, 2014
lib/misc/safe_signals.py
@@ -28,7 +28,7 @@ def safe_send(self, sender, **named):
# Call each receiver with whatever arguments it can accept.
# Return a list of tuple pairs [(receiver, response), ... ].
- for receiver in self._live_receivers(_make_id(sender)):
+ for receiver in self._live_receivers(sender):
@diox
diox added a note Feb 24, 2014

We should remove lib/misc/safe_signals entirely. It shouldn't be used anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on the diff Feb 24, 2014
manage.py
@@ -70,10 +69,6 @@
if not settings.DEBUG:
warnings.simplefilter('ignore')
-# The first thing execute_manager does is call `setup_environ`. Logging config
-# needs to access settings, so we'll setup the environ early.
-setup_environ(settings)
@diox
diox added a note Feb 24, 2014

Slightly nervous about this since there is a few things going on below that might need settings...

@washort
washort added a note Feb 24, 2014

Just importing settings is enough now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox and 1 other commented on an outdated diff Feb 24, 2014
mkt/developers/views.py
@@ -835,6 +834,7 @@ def addons_section(request, addon_id, addon, section, editable=False,
all_forms.append(additional_form)
if all(not f or f.is_valid() for f in all_forms):
+ addon.save()
@diox
diox added a note Feb 24, 2014

why ?

@washort
washort added a note Feb 25, 2014

mkt.developers.tests.test_views_edit.TestEditTechnical.test_public_stats fails without this

@diox
diox added a note Feb 25, 2014

There is a form.save() below so it really shouldn't be necessary, we should figure out what's wrong with the test

@diox
diox added a note Feb 25, 2014

https://gist.github.com/diox/edf8713381db8fd004c0 fixes it. The culprit was the af.update() call in the form, because it shared the Addon instance with the form (thanks to related models caching introduced in 1.5), the File has a post_save signal that reloads the associated Addon, causing the instance stored on the form to be reseted completely, losing the changes from the form.

I moved the af.update() call after the .save() to fix it.

@washort
washort added a note Feb 25, 2014

you're a wizard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox and 1 other commented on an outdated diff Feb 24, 2014
mkt/submit/tests/test_forms.py
@@ -186,8 +186,8 @@ def test_slug(self):
form = forms.AppDetailsBasicForm(data, request=self.request,
instance=app)
assert form.is_valid()
+ app.save()
@diox
diox added a note Feb 24, 2014

why ?

@washort
washort added a note Feb 25, 2014

test fails on app.app_slug comparison below otherwise.

@diox
diox added a note Feb 25, 2014

even with the app.reload() that you removed below ?

@washort
washort added a note Feb 25, 2014

yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox and 1 other commented on an outdated diff Feb 24, 2014
mkt/submit/views.py
if request.POST and all(f.is_valid() for f in forms.itervalues()):
+ addon.save()
@diox
diox added a note Feb 24, 2014

why ? form_basic.save(addon) below should make that redundant

@washort
washort added a note Feb 25, 2014

mkt.submit.tests.test_views.TestDetails tests fail if removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox and 2 others commented on an outdated diff Feb 24, 2014
requirements/prod.txt
-e git+https://github.com/mozilla/signing-clients@a8bd730b202391c080113d224d223463e03088e9#egg=signing-clients
-e git+https://github.com/mozilla/django-session-csrf@f00ad913c62e139d36078e8a7e07dab65a021386#egg=django-session-csrf
+-e git+https://github.com/jbalogh/django-cache-machine@449861a61bcf096b792039128f044659e3e96eb6#egg=django-cache-machine
+-e git+https://github.com/andymckay/django-quieter-formset.git@904493858e4cf8f442e993ed346ab2c34cf40cd3@#egg=django-quieter-formset
@diox
diox added a note Feb 24, 2014

I'd prefer to wait for the changes to django-quieter-formset and django-cache-machine are merged before merging this PR. The less requirements we have from personal forks the better.

@washort
washort added a note Feb 24, 2014

OK. django-quieter-formset has a release with my changes, I guess we should ask @jbalogh to do a django-cache-machine release.

@jbalogh
jbalogh added a note Feb 24, 2014

@washort Do you want to be a collab on the cache-machine repo? I don't use it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on an outdated diff Feb 25, 2014
apps/addons/tests/test_models.py
@@ -2212,7 +2213,8 @@ def test_extract_no_files(self):
def test_extract_not_language_pack(self):
File.objects.create(platform=self.platform_mob, version=self.version,
- filename=self.xpi_path('langpack-localepicker'))
+ filename=self.xpi_path('langpack-localepicker'),
+ status=amo.STATUS_PUBLIC)
assert self.addon.get_localepicker()
@diox
diox added a note Feb 25, 2014

We should reload the addon here (the File creation might have changed something on it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox diox commented on the diff Feb 25, 2014
settings_test.py
@@ -79,7 +79,7 @@ def _polite_tmpdir():
# COUNT() caching can't be invalidated, it just expires after x seconds. This
# is just too annoying for tests, so disable it.
-CACHE_COUNT_TIMEOUT = None
+CACHE_COUNT_TIMEOUT = -1
@diox
diox added a note Feb 25, 2014

Supposing you can import it there, caching.base.NO_CACHE would be better IMHO. According to the code, None should work though:

        if self.timeout == NO_CACHE or TIMEOUT is None:
            return super_count()
        else:
            return cached_with(self, super_count, query_string, TIMEOUT)

Is that change really necessary ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@diox
diox commented Feb 25, 2014

r+wc from me if tests pass after rebasing against master :)

@washort
washort commented Feb 26, 2014

well I merged this and now both CI and -dev deploy are broken with no meaningful errors. reverting until I can get ops help.

@washort washort closed this Mar 27, 2014
@washort washort deleted the washort:django16 branch Mar 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.