Esempio n. 1
0
def configure_plugin(request, core_service, name):
    # if there is no plugin named module, then return a 404
    try:
        plugin = core_service._plugins[name]
        if plugin.configs is None:
            logger.log_error("plugin %s doesn't have a Configurator" % name)
            raise Http404 
    except KeyError:
        logger.log_error("couldn't find plugin %s" % name)
        raise Http404
    except Exception, e:
        logger.log_error("couldn't configure plugin %s: %s" % (name, e))
        raise Http500
Esempio n. 2
0
                raise ApiResponse(400, reason="Title is empty")
            if len(title) > 80:
                raise ApiResponse(400, reason="Title is longer than 80 characters")
            try:
                playlist.name = title
                playlist.save()
            except Exception, e:
                logger.log_debug("playlist_show: edit failed: %s" % str(e))
                raise ApiResponse(400, reason=str(e))
            raise ApiResponse(200)
        elif request.POST['action'] == 'add':
            for id in request.POST.getlist('ids'):
                song = Song.objects.get(id=int(id))
                playlist.append_song(song)
                logger.log_debug("playlist_show: added song %s" % song.name)
            playlist.save()
            raise ApiResponse(200)
        elif request.POST['action'] == 'delete':
            try:
                for index in request.POST['indices']:
                    index = int(index)
                    playlist.remove_song(index)
            except Exception, e:
                raise ApiResponse(400, reason=str(e))
            raise ApiResponse(200)
    except ApiResponse, resp:
        return resp
    except Exception, e:
        logger.log_error("playlist_show: %s" % e)
    return HttpResponseServerError()