changeset 9:aa4eab6dc994

* dont set node width, height; * move save() to its own function
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 02 Jan 2011 11:39:45 -0800
parents 1d16bde33eee
children 1329127709de
files example/example.py svgsitemap/middleware.py
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/example/example.py	Wed Dec 29 00:25:48 2010 -0800
+++ b/example/example.py	Sun Jan 02 11:39:45 2011 -0800
@@ -14,7 +14,7 @@
     inifile = os.path.join(dirname, 'example.gv.txt')
     svgfile = os.path.join(dirname, 'example.svg')
     app = MapserverMiddleware(example, svgfile)
-    app = SVGSiteMap(app, file=inifile, output=svgfile, name='foo.com')
+    app = SVGSiteMap(app, file=inifile, output=svgfile)
     return app
 
 if __name__ == '__main__':
--- a/svgsitemap/middleware.py	Wed Dec 29 00:25:48 2010 -0800
+++ b/svgsitemap/middleware.py	Sun Jan 02 11:39:45 2011 -0800
@@ -111,14 +111,15 @@
         self.graph.node_attr['fontname'] = self.fontname
         self.graph.node_attr['fontsize'] = self.fontsize
         self.graph.node_attr['shape'] = self.shape
-        self.graph.node_attr['width'] = '0.1'
-        self.graph.node_attr['height'] = '0.1'
         self.graph.edge_attr['color'] = self.edgecolor
         self.graph.edge_attr['fontcolor'] = self.fontcolor
         self.graph.edge_attr['fontname'] = self.fontname
         self.graph.edge_attr['fontsize'] = self.fontsize
         self.graph.edge_attr['len'] = self.len
         self.graph.edge_attr['arrowsize'] = self.arrowsize
+
+        if self.edges:
+            self.save()
         
     def __call__(self, environ, start_response):
         request = Request(environ)
@@ -176,10 +177,7 @@
             node.attr['label'] = url
             node.attr['href'] = url
 
-        if self.file:
-            self.graph.write(self.file)
-        if self.output:
-            self.graph.draw(self.output, prog='neato')
+        self.save()
 
     def exclude(self, *urls):
         """tell whether the edge is excluded"""
@@ -204,3 +202,9 @@
         else:
             for edge in self.graph.edges():
                 edge.attr['style'] = ''
+
+    def save(self):
+        if self.file:
+            self.graph.write(self.file)
+        if self.output:
+            self.graph.draw(self.output, prog='neato')