Skip to contentSkip to conversation

Revert "toaster: add layer source in admin throws an error"

PATCH In review Alex DAMIAN 2 participants 2 messages Apr 27, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "toaster: add layer source in admin throws an error"

From: Alexandru DAMIAN <[email protected]>

This reverts commit 4de721aa75a4aaad186312443726e6daa764934b.

---
 lib/toaster/orm/models.py | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
lib/toaster/orm/models.py +6 -14
index b9bb896..cccf7f3 100644
@@ -646,25 +646,17 @@ class LayerSource(models.Model):
         raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self)))
 
     def save(self, *args, **kwargs):
-        if self.sourcetype == LayerSource.TYPE_LOCAL:
-            self.__class__ = LocalLayerSource
-        elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
-            self.__class__ = LayerIndexLayerSource
-        elif self.sourcetype == LayerSource.TYPE_IMPORTED:
-            self.__class__ = ImportedLayerSource
+        if isinstance(self, LocalLayerSource):
+            self.sourcetype = LayerSource.TYPE_LOCAL
+        elif isinstance(self, LayerIndexLayerSource):
+            self.sourcetype = LayerSource.TYPE_LAYERINDEX
+        elif isinstance(self, ImportedLayerSource):
+            self.sourcetype = LayerSource.TYPE_IMPORTED
         elif self.sourcetype == None:
             raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.")
         return super(LayerSource, self).save(*args, **kwargs)
 
     def get_object(self):
-        # preset an un-initilized object
-        if None == self.name:
-            self.name=""
-        if None == self.apiurl:
-            self.apiurl=""
-        if None == self.sourcetype:
-            self.sourcetype=LayerSource.TYPE_LOCAL
-
         if self.sourcetype == LayerSource.TYPE_LOCAL:
             self.__class__ = LocalLayerSource
         elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
Signature · 1 line
1.9.1
#1 lore raw

Hi Alex,

Quoted 4 lines · On Monday 27 April 2015 15:24:25 Alex DAMIAN wrote:

From: Alexandru DAMIAN <[email protected]>

This reverts commit 4de721aa75a4aaad186312443726e6daa764934b.
---

When we revert patches, we need something in the message explaining why we are doing the revert.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre