X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/de93104a2513acc5a378496c6bf6ab7ed0d45d60..30ac8daa26e44d77b606eda4338c392f76245879:/apps/api/views.py?ds=sidebyside diff --git a/apps/api/views.py b/apps/api/views.py old mode 100644 new mode 100755 index b96fc470..3e9cb015 --- a/apps/api/views.py +++ b/apps/api/views.py @@ -1,6 +1,10 @@ # Create your views here. +import logging +log = logging.getLogger('platforma.render') + from django.http import HttpResponse +import librarian from librarian import html from lxml import etree from StringIO import StringIO @@ -12,17 +16,16 @@ def render(request): style_filename = html.get_stylesheet('partial') data = request.POST['fragment'] - path = request.POST['part'] + path = request.POST['chunk'] base, me = path.rsplit('/', 1) match = re.match(r'([^\[]+)\[(\d+)\]', me) - tag, pos = match.groups() - - print "Redner:", path, base, tag, pos + tag, pos = match.groups() style = etree.parse(style_filename) - data = LINE_SWAP_EXPR.sub(u'
\n', data) + data = u'<%s>%s' % (tag, LINE_SWAP_EXPR.sub(u'
\n', data), tag) + log.info(data) doc = etree.parse( StringIO(data) ) opts = { @@ -31,11 +34,5 @@ def render(request): 'base-offset': pos, } - print opts - result = doc.xslt(style, **opts) - - print result - - return HttpResponse( - etree.tostring(result, encoding=unicode, pretty_print=True) ) \ No newline at end of file + return HttpResponse( librarian.serialize_children(result.getroot()[0]) ) \ No newline at end of file