def create_object_by_id(self, sc_id): """ If we have this object in socialite -> query from db and return else -> fetch from SoundCloud """ from utils import SoundCloudProcessor try: obj = self.get(sid=sc_id) return obj except SoundCloud.DoesNotExist: pass sc_obj = SoundCloudProcessor.fetch(sc_id) if sc_obj: sc_obj.save() return sc_obj print sc_id # Errors return None
def search(self, q): from utils import SoundCloudProcessor sounds = SoundCloudProcessor.search(q) return sounds