From b4708fb284897894159389025014b5e3c69dcf81 Mon Sep 17 00:00:00 2001 From: posativ Date: Thu, 25 Oct 2012 20:08:28 +0200 Subject: [PATCH] modify can return plain text and marked up content --- isso/comment.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/isso/comment.py b/isso/comment.py index b1f1ef3..2296698 100644 --- a/isso/comment.py +++ b/isso/comment.py @@ -51,11 +51,12 @@ def get(app, environ, request, path, id=None): if not rv: abort(404) - if isinstance(rv, list): - for item in rv: - item.text = app.markup.convert(item.text) - else: - rv.text = app.markup.convert(rv.text) + if request.args.get('plain', '0') == '0': + if isinstance(rv, list): + for item in rv: + item.text = app.markup.convert(item.text) + else: + rv.text = app.markup.convert(rv.text) return Response(json.dumps(rv), 200, content_type='application/json') @@ -77,6 +78,7 @@ def modify(app, environ, request, path, id): if request.method == 'PUT': try: rv = app.db.update(path, id, models.Comment.fromjson(request.data)) + rv.text = app.markup.convert(rv.text) return Response(json.dumps(rv), 200, content_type='application/json') except ValueError as e: return Response(unicode(e), 400)