Author: adc Date: Sat May 10 20:57:08 2014 New Revision: 1593734 URL: http://svn.apache.org/r1593734 Log: Support archives
Modified: labs/panopticon/src/asf/wsgi/ezmlm.py Modified: labs/panopticon/src/asf/wsgi/ezmlm.py URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/wsgi/ezmlm.py?rev=1593734&r1=1593733&r2=1593734&view=diff ============================================================================== --- labs/panopticon/src/asf/wsgi/ezmlm.py (original) +++ labs/panopticon/src/asf/wsgi/ezmlm.py Sat May 10 20:57:08 2014 @@ -181,6 +181,61 @@ def asf_remove_moderator(mailing_list, m return ezmlm_remove_moderator(list_path, moderator) +# noinspection PyUnusedLocal +@app.route('/v1/public/lists/<mailing_list>/archives') +def public_list_archives(mailing_list): + flask.abort(401) + + +# noinspection PyUnusedLocal +@app.route('/v1/committer/lists/<mailing_list>/archives') +def committer_list_archives(mailing_list): + flask.abort(401) + + +@app.route('/v1/asf/lists/<mailing_list>/archives') +@json_result +def asf_list_archives(mailing_list): + list_path = path_from_root_and_list(app.config['LIST_ROOT_PATH'], mailing_list) + + if not os.path.exists(list_path): + flask.abort(500) + + ezmlm = Ezmlm(list_path) + + return {'number': ezmlm.num_messages} + + +# noinspection PyUnusedLocal +@app.route('/v1/public/lists/<mailing_list>/archives/<int:message_id>') +def public_get_archives(mailing_list, message_id): + flask.abort(401) + + +# noinspection PyUnusedLocal +@app.route('/v1/committer/lists/<mailing_list>/archives/<int:message_id>') +def committer_get_archives(mailing_list, message_id): + flask.abort(401) + + +@app.route('/v1/asf/lists/<mailing_list>/archives/<int:message_id>') +def asf_get_archives(mailing_list, message_id): + list_path = path_from_root_and_list(app.config['LIST_ROOT_PATH'], mailing_list) + + if not os.path.exists(list_path): + flask.abort(500) + + ezmlm = Ezmlm(list_path) + + message_path = ezmlm.path_to_archived_message(message_id) + if not os.path.exists(message_path): + flask.abort(404) + + response = flask.make_response(open(message_path).read()) + response.headers["content-type"] = "text/plain" + return response + + def path_from_root_and_list(list_root_path, mailing_list): local, domain = mailing_list.split('@') --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@labs.apache.org For additional commands, e-mail: commits-h...@labs.apache.org