Commit 438fa91c6424af5dc156ea4bbab2bb93d0ae88bf

  • avatar
  • arvind
  • Sat Mar 30 08:59:02 IST 2013
Bug fixes
		- Fixing /submit. request.form['data'] is a stringified JSON. USe json.lods to get the JSON.
  • Diff rendering mode:
  • inline
  • side by side

fetch.py

10import lxml.html10import lxml.html
11import urllib211import urllib2
12import StringIO12import StringIO
13import json
1314
15
14app = Flask(__name__)16app = Flask(__name__)
1517
1618
43 return jsonify(ret)43 return jsonify(ret)
4444
4545
46@app.route('/search', methods=['GET'])
47def search():
48 connection = pymongo.Connection()
49 db = connection['mural']
50 collection = db['data']
51 y = 0
52 ret = {}
53 for i in collection.find():
54 try:
55 if request.args['data'] in i['nodes']:
56 del(i['_id'])
57 ret[y] = i
58 y = y + 1
59 except:
60 pass
61 return render_template('blank.html', content = ret)
46@app.route('/submit', methods=['POST'])62@app.route('/submit', methods=['POST'])
47def submit():63def submit():
48 c = pymongo.Connection()64 c = pymongo.Connection()
49 db = c['mural']65 db = c['mural']
50 coll = db['data']66 coll = db['data']
67 requestData = json.loads(request.form['data'])
51 try:68 try:
52 for i in d:
53 coll.insert(request.args['data'])
54 response = make_response()
55 response.status = '200 OK'
56 response.status_code = 200
57 return response
69 for i in requestData:
70 coll.insert(i)
71 response = make_response()
72 response.status = '200 OK'
73 response.status_code = 200
74 return response
58 except:75 except:
59 response = make_response()76 response = make_response()
60 response.status = "500"77 response.status = "500"
105 root.head.append(link)105 root.head.append(link)
106106
107 return lxml.html.tostring(root)107 return lxml.html.tostring(root)
108
108109
109#Log the errors, don't depend on apache to log it for you.110#Log the errors, don't depend on apache to log it for you.
110 fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a')111 fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a')

static/myVector.js

60};60};
61function onFeatureSelect(feature)61function onFeatureSelect(feature)
62{62{
63 for(var i in ans.ans)
63 for(var i in ans.ans)
64 {64 {
65 if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom'])65 if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom'])
66 {66 {
244 map.addLayers([box2, box3]);244 map.addLayers([box2, box3]);
245245
246 selectControl = new OpenLayers.Control.SelectFeature(box3,246 selectControl = new OpenLayers.Control.SelectFeature(box3,
247 {onSelect: onFeatureSelect});
247 {hover:true, clickout: true, onSelect: onFeatureSelect});
248248
249 drawControls = {249 drawControls = {
250 box : new OpenLayers.Control.DrawFeature(boxes,250 box : new OpenLayers.Control.DrawFeature(boxes,