1.1 --- a/parsers/SVGChart.py Sun Oct 16 23:21:17 2011 +0200
1.2 +++ b/parsers/SVGChart.py Mon Oct 17 00:38:34 2011 +0200
1.3 @@ -6,10 +6,15 @@
1.4 @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.5 """
1.6
1.7 -from MoinMoin.action import cache
1.8 from MoinMoin import wikiutil
1.9 +from MoinMoin.action import AttachFile
1.10 from SVGChartSupport import get_chart, get_dimensions
1.11
1.12 +try:
1.13 + from hashlib import sha1
1.14 +except ImportError:
1.15 + from sha import new as sha1
1.16 +
1.17 Dependencies = ["pages"]
1.18
1.19 # Parser support.
1.20 @@ -52,18 +57,19 @@
1.21 page = request.page
1.22 _ = request.getText
1.23
1.24 - cache_key = cache.key(request, itemname=page.page_name, content="%s,%s,%s,%s,%s" % (
1.25 - self.width, self.height, self.xorigin, self.yorigin, self.raw))
1.26 + data = "%s,%s,%s,%s,%s" % (self.width, self.height, self.xorigin, self.yorigin, self.raw)
1.27 + filename = "SVGChart-%s.svg" % sha1(data).hexdigest()
1.28 + pagename = page.page_name
1.29
1.30 - if not cache.exists(request, cache_key):
1.31 + if not AttachFile.exists(request, pagename, filename):
1.32 width, height, chart = get_chart(self.data, self.width, self.height, self.xorigin, self.yorigin,
1.33 styles_url="%s/%s/css/svgchart.css" % (request.cfg.url_prefix_static, request.theme.name))
1.34 - cache.put(request, cache_key, chart, content_type="image/svg+xml")
1.35 + AttachFile.add_attachment(request, pagename, filename, chart.encode("utf-8"))
1.36 else:
1.37 width, height = get_dimensions(self.data, self.width, self.height, self.xorigin, self.yorigin)
1.38
1.39 request.write(fmt.div(1, css_class="svgchart"))
1.40 - request.write(fmt.transclusion(1, data=cache.url(request, cache_key), width=width, height=height))
1.41 + request.write(fmt.transclusion(1, data=AttachFile.getAttachUrl(pagename, filename, request), width=width, height=height))
1.42 request.write(fmt.text(_("SVG chart of CSV data.")))
1.43 request.write(fmt.transclusion(0))
1.44 request.write(fmt.div(0))