web/views/schema.py
changeset 9383 7b3fa5a7a5a3
parent 9299 c5eed908117d
child 10405 7b27a7443180
--- a/web/views/schema.py	Thu Dec 12 16:17:25 2013 +0100
+++ b/web/views/schema.py	Mon Jan 06 12:01:35 2014 +0100
@@ -24,6 +24,7 @@
 
 import tempfile
 import os, os.path as osp
+import codecs
 
 from logilab.common.graph import GraphGenerator, DotBackend
 from logilab.common.ureports import Section, Table
@@ -40,7 +41,6 @@
 from cubicweb.view import EntityView, StartupView
 from cubicweb import tags, uilib
 from cubicweb.web import action, facet, schemaviewer
-from cubicweb.web.views import TmpFileViewMixin
 from cubicweb.web.views import uicfg, primary, baseviews, tabs, tableview, ibreadcrumbs
 
 ALWAYS_SKIP_TYPES = BASE_TYPES | SCHEMA_TYPES
@@ -625,6 +625,8 @@
     __regid__ = 'schemagraph'
 
     def call(self, etype=None, rtype=None, alt=''):
+        if 'MSIE 8' in self._cw.useragent():
+            return
         schema = self._cw.vreg.schema
         if etype:
             assert rtype is None
@@ -652,22 +654,12 @@
                                                   'splines':'true',
                                                   'sep':'0.2',
                                               }))
-        # map file
-        pmap, mapfile = tempfile.mkstemp(".map")
-        os.close(pmap)
-        # image file
-        fd, tmpfile = tempfile.mkstemp('.png')
+        # svg image file
+        fd, tmpfile = tempfile.mkstemp('.svg')
         os.close(fd)
-        generator.generate(visitor, prophdlr, tmpfile, mapfile)
-        filekeyid = make_uid()
-        self._cw.session.data[filekeyid] = tmpfile
-        self.w(u'<img src="%s" alt="%s" usemap="#schema" />' % (
-            xml_escape(self._cw.build_url(vid='tmppng', tmpfile=filekeyid)),
-            xml_escape(self._cw._(alt))))
-        stream = open(mapfile, 'r').read()
-        stream = stream.decode(self._cw.encoding)
-        self.w(stream)
-        os.unlink(mapfile)
+        generator.generate(visitor, prophdlr, tmpfile)
+        with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile:
+            self.w(svgfile.read())
 
 # breadcrumbs ##################################################################