summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 625eb1ee85..4a6ca8f2b1 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -640,17 +640,25 @@ class LayerSource(models.Model):
640 raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self))) 640 raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self)))
641 641
642 def save(self, *args, **kwargs): 642 def save(self, *args, **kwargs):
643 if isinstance(self, LocalLayerSource): 643 if self.sourcetype == LayerSource.TYPE_LOCAL:
644 self.sourcetype = LayerSource.TYPE_LOCAL 644 self.__class__ = LocalLayerSource
645 elif isinstance(self, LayerIndexLayerSource): 645 elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
646 self.sourcetype = LayerSource.TYPE_LAYERINDEX 646 self.__class__ = LayerIndexLayerSource
647 elif isinstance(self, ImportedLayerSource): 647 elif self.sourcetype == LayerSource.TYPE_IMPORTED:
648 self.sourcetype = LayerSource.TYPE_IMPORTED 648 self.__class__ = ImportedLayerSource
649 elif self.sourcetype == None: 649 elif self.sourcetype == None:
650 raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.") 650 raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.")
651 return super(LayerSource, self).save(*args, **kwargs) 651 return super(LayerSource, self).save(*args, **kwargs)
652 652
653 def get_object(self): 653 def get_object(self):
654 # preset an un-initilized object
655 if None == self.name:
656 self.name=""
657 if None == self.apiurl:
658 self.apiurl=""
659 if None == self.sourcetype:
660 self.sourcetype=LayerSource.TYPE_LOCAL
661
654 if self.sourcetype == LayerSource.TYPE_LOCAL: 662 if self.sourcetype == LayerSource.TYPE_LOCAL:
655 self.__class__ = LocalLayerSource 663 self.__class__ = LocalLayerSource
656 elif self.sourcetype == LayerSource.TYPE_LAYERINDEX: 664 elif self.sourcetype == LayerSource.TYPE_LAYERINDEX: