annotate example/example.py @ 20:f9cf249dd512

bump version to respect formatting fixes
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 02 Jan 2011 20:41:25 -0800
parents aa4eab6dc994
children 1b077cb84be5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
1 import os
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 from svgsitemap import *
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 from webob import Request, Response
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 def example(environ, start_response):
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 link = '<a href="/%s">%s</a>'
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 body = '<br/>'.join([link % (i,i) for i in range(30)])
2
30d03e830354 compute line widths
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
8 body = '<html><body><a href="/map">map</a><br/>%s</body></html>' % body
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
9 response = Response(content_type='text/html', body=body)
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 return response(environ, start_response)
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 def factory():
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
13 dirname = os.path.dirname(os.path.abspath(__file__))
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
14 inifile = os.path.join(dirname, 'example.gv.txt')
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
15 svgfile = os.path.join(dirname, 'example.svg')
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
16 app = MapserverMiddleware(example, svgfile)
9
aa4eab6dc994 * dont set node width, height; * move save() to its own function
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
17 app = SVGSiteMap(app, file=inifile, output=svgfile)
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
18 return app
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 if __name__ == '__main__':
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 from wsgiref import simple_server
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
22 server = simple_server.make_server(host='0.0.0.0', port=int(54321), app=factory())
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 server.serve_forever()