launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #09309
[Merge] lp:~rvb/maas/dj-14-field into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/dj-14-field into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/dj-14-field/+merge/112500
This branch is the first of a series to fix MAAS to be compatible with Django 1.4 (the version Quantal) while keeping the compatibility with Django 1.3 (the version in Precise).
This branch fixes our custom's fields' get_db_prep_value method which, in order to be Django 1.4-compatible (and support multiple database), that method should support two new parameters (see [1] for details). I've made 'connection' optional to still support Django 1.3.
[1] https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#django.db.models.Field.get_db_prep_value
Drive-by fix: fixed the way we hack INSTALLED_APPS in our test to deal with the case where INSTALLED_APPS is a tuple (and not a list)… which happens to be the case in Django 1.4 (remember that the settings we access from django.conf.settings are a Django-processed version of the settings store in settings.py et al).
--
https://code.launchpad.net/~rvb/maas/dj-14-field/+merge/112500
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/dj-14-field into lp:maas.
=== modified file 'src/maasserver/fields.py'
--- src/maasserver/fields.py 2012-04-16 10:00:51 +0000
+++ src/maasserver/fields.py 2012-06-28 07:14:26 +0000
@@ -108,7 +108,7 @@
else:
return None
- def get_db_prep_value(self, value):
+ def get_db_prep_value(self, value, connection=None, prepared=False):
"""python -> db: json dump."""
if value is not None:
return dumps(deepcopy(value))
=== modified file 'src/maastesting/djangotestcase.py'
--- src/maastesting/djangotestcase.py 2012-04-25 10:27:57 +0000
+++ src/maastesting/djangotestcase.py 2012-06-28 07:14:26 +0000
@@ -78,8 +78,9 @@
def _pre_setup(self):
# Add the models to the db.
- self._original_installed_apps = list(settings.INSTALLED_APPS)
+ self._original_installed_apps = settings.INSTALLED_APPS
assert self.app is not None, "TestCase.app must be defined!"
+ settings.INSTALLED_APPS = list(settings.INSTALLED_APPS)
settings.INSTALLED_APPS.append(self.app)
loading.cache.loaded = False
# Use Django's 'syncdb' rather than South's.
=== modified file 'src/metadataserver/fields.py'
--- src/metadataserver/fields.py 2012-04-16 10:00:51 +0000
+++ src/metadataserver/fields.py 2012-06-28 07:14:26 +0000
@@ -92,7 +92,7 @@
"Invalid BinaryField value (expected unicode): '%s'"
% repr(value))
- def get_db_prep_value(self, value):
+ def get_db_prep_value(self, value, connection=None, prepared=False):
"""Django overridable: convert python-side value to database value."""
if value is None:
# Equivalent of a NULL.
Follow ups