modify can return plain text and marked up content

This commit is contained in:
posativ 2012-10-25 20:08:28 +02:00
parent ba631eaa57
commit b4708fb284

View File

@ -51,6 +51,7 @@ def get(app, environ, request, path, id=None):
if not rv: if not rv:
abort(404) abort(404)
if request.args.get('plain', '0') == '0':
if isinstance(rv, list): if isinstance(rv, list):
for item in rv: for item in rv:
item.text = app.markup.convert(item.text) item.text = app.markup.convert(item.text)
@ -77,6 +78,7 @@ def modify(app, environ, request, path, id):
if request.method == 'PUT': if request.method == 'PUT':
try: try:
rv = app.db.update(path, id, models.Comment.fromjson(request.data)) 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') return Response(json.dumps(rv), 200, content_type='application/json')
except ValueError as e: except ValueError as e:
return Response(unicode(e), 400) return Response(unicode(e), 400)