def main(request): username = sys.argv[2] password = sys.argv[3] with transaction.manager: user = User( username=username, plain_password=password, ) DBSession.add(user)
def api_queue_add_view(request): music_id = request.POST.get("music_id", None) if music_id is None: raise HTTPBadRequest try: music_id = int(music_id) except ValueError: raise HTTPBadRequest music = DBSession.query(Music).filter_by(id=music_id).first() if not music: raise HTTPBadRequest data = MusicInfoMapper(music).as_dict() rq = RedisQueue( server=request.registry.settings["redis_server"], password=request.registry.settings["redis_password"], ) rq.enqueue("play", data) return {}
def api_list_view(request): musics = DBSession.query(Music).all() ret = [MusicMapper(music).as_dict() for music in musics] return ret