fix some issues in DotGraphView, and enhance reusability stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 06 Oct 2010 15:32:59 +0200
branchstable
changeset 6405 6989f0e02542
parent 6403 b7e24d49639b
child 6406 39663630ca3c
fix some issues in DotGraphView, and enhance reusability
web/views/dotgraphview.py
--- a/web/views/dotgraphview.py	Wed Oct 06 14:56:43 2010 +0200
+++ b/web/views/dotgraphview.py	Wed Oct 06 15:32:59 2010 +0200
@@ -31,14 +31,15 @@
 
 class DotGraphView(EntityView):
     __abstract__ = True
-
+    backend_class = DotBackend
+    backend_kwargs = {'ratio': 'compress', 'size': '30,10'}
     def cell_call(self, row, col):
         entity = self.cw_rset.get_entity(row, col)
         visitor = self.build_visitor(entity)
         prophdlr = self.build_dotpropshandler()
         graphname = 'dotgraph%s' % str(entity.eid)
-        generator = GraphGenerator(DotBackend(graphname, None,
-                                              ratio='compress', size='30,10'))
+        generator = GraphGenerator(self.backend_class(graphname, None,
+                                                      **self.backend_kwargs))
         # map file
         pmap, mapfile = tempfile.mkstemp(".map", graphname)
         os.close(pmap)
@@ -50,7 +51,7 @@
         self._cw.session.data[filekeyid] = tmpfile
         self.w(u'<img src="%s" alt="%s" usemap="#%s" />' % (
             xml_escape(entity.absolute_url(vid='tmppng', tmpfile=filekeyid)),
-            xml_escape(self._cw._('Data connection graph for %s') % entity.name),
+            xml_escape(self._cw._('Data connection graph for %s') % entity.dc_title()),
             graphname))
         stream = open(mapfile, 'r').read()
         stream = stream.decode(self._cw.encoding)
@@ -61,7 +62,7 @@
         raise NotImplementedError
 
     def build_dotpropshandler(self):
-        return DotGraphPropsHandler(self._cw)
+        return DotPropsHandler(self._cw)
 
 
 class DotPropsHandler(object):