Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/prep-config-migration 
into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/prep-config-migration/+merge/104203

As per the migration plan.  This prepares the Config and ConfigManager classes 
for migration on Tuesday 2012-04-08.

While I was at it, I also added the required DefaultMeta class to the other 
maasserver models.  Saves adding it in every migration prep branch and removing 
it again in every actual migration branch.

As part of keeping the migration simple and minimizing each model module's 
exposed interface, I removed the config_manager reference and just defined the 
ConfigManager singleton in its usual place: Config.objects.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/prep-config-migration/+merge/104203
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~jtv/maas/prep-config-migration into lp:maas.
=== modified file 'src/maasserver/models/__init__.py'
--- src/maasserver/models/__init__.py	2012-04-30 03:55:22 +0000
+++ src/maasserver/models/__init__.py	2012-05-01 05:24:18 +0000
@@ -59,6 +59,7 @@
 from django.db.models.signals import post_save
 from django.shortcuts import get_object_or_404
 from django.utils.safestring import mark_safe
+from maasserver import DefaultMeta
 from maasserver.enum import (
     ARCHITECTURE,
     ARCHITECTURE_CHOICES,
@@ -387,6 +388,9 @@
 
     """
 
+    class Meta(DefaultMeta):
+        """Needed for South to recognize this model."""
+
     system_id = models.CharField(
         max_length=41, unique=True, default=generate_node_system_id,
         editable=False)
@@ -602,7 +606,8 @@
     mac_address = MACAddressField(unique=True)
     node = models.ForeignKey(Node, editable=False)
 
-    class Meta:
+    class Meta(DefaultMeta):
+        verbose_name = "MAC address"
         verbose_name_plural = "MAC addresses"
 
     def __unicode__(self):
@@ -689,6 +694,9 @@
 
     """
 
+    class Meta(DefaultMeta):
+        """Needed for South to recognize this model."""
+
     objects = UserProfileManager()
     user = models.OneToOneField(User)
 
@@ -839,6 +847,10 @@
     :ivar user: The user which owns the key.
     :ivar key: The ssh public key.
     """
+
+    class Meta(DefaultMeta):
+        """Needed for South to recognize this model."""
+
     objects = SSHKeyManager()
 
     user = models.ForeignKey(User, null=False, editable=False)
@@ -978,6 +990,9 @@
     :ivar data: The file's actual data.
     """
 
+    class Meta(DefaultMeta):
+        """Needed for South to recognize this model."""
+
     storage = FileSystemStorage()
 
     upload_dir = "storage"
@@ -994,6 +1009,7 @@
         return self.filename
 
 
+# Due for model migration on 2012-04-08
 def get_default_config():
     return {
         ## settings default values.
@@ -1018,10 +1034,12 @@
         }
 
 
+# Due for model migration on 2012-04-08
 # Default values for config options.
 DEFAULT_CONFIG = get_default_config()
 
 
+# Due for model migration on 2012-04-08
 class ConfigManager(models.Manager):
     """A utility to manage the configuration settings.
 
@@ -1097,9 +1115,7 @@
             connection(sender, instance, created, **kwargs)
 
 
-config_manager = ConfigManager()
-
-
+# Due for model migration on 2012-04-08
 class Config(models.Model):
     """Configuration settings.
 
@@ -1109,17 +1125,21 @@
     :type value: Any pickleable python object.
     """
 
+    class Meta(DefaultMeta):
+        """Needed for South to recognize this model."""
+
     name = models.CharField(max_length=255, unique=False)
     value = JSONObjectField(null=True)
 
-    objects = config_manager
+    objects = ConfigManager()
 
     def __unicode__(self):
         return "%s: %s" % (self.name, self.value)
 
 
-# Connect config_manager._config_changed the post save signal of Config.
-post_save.connect(config_manager._config_changed, sender=Config)
+# Due for model migration on 2012-04-08
+# Connect config manager's _config_changed to Config's post-save signal.
+post_save.connect(Config.objects._config_changed, sender=Config)
 
 
 # Register the models in the admin site.

=== modified file 'src/maasserver/tests/test_maasavahi.py'
--- src/maasserver/tests/test_maasavahi.py	2012-04-19 15:48:46 +0000
+++ src/maasserver/tests/test_maasavahi.py	2012-05-01 05:24:18 +0000
@@ -19,10 +19,7 @@
     MAASAvahiService,
     setup_maas_avahi_service,
     )
-from maasserver.models import (
-    Config,
-    config_manager,
-    )
+from maasserver.models import Config
 from maastesting.djangotestcase import DjangoTestCase
 
 
@@ -64,7 +61,7 @@
         # Unregister other signals from Config, otherwise
         # the one registered in urls.py, will interfere with these tests
         self.patch(
-            config_manager, '_config_changed_connections', defaultdict(set))
+            Config.objects, '_config_changed_connections', defaultdict(set))
 
         mock_avahi = MockZeroconfServiceFactory()
         self.patch(

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to