1 # Create your views here.
4 log = logging.getLogger('platforma.render')
6 from django.http import HttpResponse
8 from librarian import html
10 from StringIO import StringIO
13 LINE_SWAP_EXPR = re.compile(r'/\s', re.MULTILINE | re.UNICODE);
16 style_filename = html.get_stylesheet('partial')
18 data = request.POST['fragment']
19 path = request.POST['chunk']
21 base, me = path.rsplit('/', 1)
22 match = re.match(r'([^\[]+)\[(\d+)\]', me)
23 tag, pos = match.groups()
25 style = etree.parse(style_filename)
27 data = u'<chunk>%s</chunk>' % LINE_SWAP_EXPR.sub(u'<br />\n', data)
29 doc = etree.parse( StringIO(data) )
32 'with-paths': 'boolean(1)',
33 'base-path': "'%s'" % base,
37 result = doc.xslt(style, **opts)
38 log.info( str(doc), str(result) )
40 return HttpResponse( librarian.serialize_children(result.getroot()) )