1414"""
1515from __future__ import absolute_import
1616
17+ import csv
1718import json
1819
1920from elasticsearch .exceptions import TransportError
2526
2627from annotator .atoi import atoi
2728from annotator .annotation import Annotation
29+ from annotator .elasticsearch import RESULTS_MAX_SIZE
2830
2931store = Blueprint ('store' , __name__ )
3032
@@ -90,7 +92,7 @@ def root():
9092 'read' : {
9193 'method' : 'GET' ,
9294 'url' : url_for ('.read_annotation' ,
93- id = ':id' ,
95+ docid = ':id' ,
9496 _external = True ),
9597 'desc' : "Get an existing annotation"
9698 },
@@ -99,7 +101,7 @@ def root():
99101 'url' :
100102 url_for (
101103 '.update_annotation' ,
102- id = ':id' ,
104+ docid = ':id' ,
103105 _external = True ),
104106 'query' : {
105107 'refresh' : {
@@ -113,7 +115,7 @@ def root():
113115 'delete' : {
114116 'method' : 'DELETE' ,
115117 'url' : url_for ('.delete_annotation' ,
116- id = ':id' ,
118+ docid = ':id' ,
117119 _external = True ),
118120 'desc' : "Delete an annotation"
119121 }
@@ -173,7 +175,7 @@ def create_annotation():
173175 refresh = request .args .get ('refresh' ) != 'false'
174176 annotation .save (refresh = refresh )
175177
176- location = url_for ('.read_annotation' , id = annotation ['id' ])
178+ location = url_for ('.read_annotation' , docid = annotation ['id' ])
177179
178180 return jsonify (annotation ), 201 , {'Location' : location }
179181 else :
@@ -182,9 +184,9 @@ def create_annotation():
182184
183185
184186# READ
185- @store .route ('/annotations/<id >' )
186- def read_annotation (id ):
187- annotation = g .annotation_class .fetch (id )
187+ @store .route ('/annotations/<docid >' )
188+ def read_annotation (docid ):
189+ annotation = g .annotation_class .fetch (docid )
188190 if not annotation :
189191 return jsonify ('Annotation not found!' , status = 404 )
190192
@@ -196,9 +198,9 @@ def read_annotation(id):
196198
197199
198200# UPDATE
199- @store .route ('/annotations/<id >' , methods = ['POST' , 'PUT' ])
200- def update_annotation (id ):
201- annotation = g .annotation_class .fetch (id )
201+ @store .route ('/annotations/<docid >' , methods = ['POST' , 'PUT' ])
202+ def update_annotation (docid ):
203+ annotation = g .annotation_class .fetch (docid )
202204 if not annotation :
203205 return jsonify ('Annotation not found! No update performed.' ,
204206 status = 404 )
@@ -209,7 +211,7 @@ def update_annotation(id):
209211
210212 if request .json is not None :
211213 updated = _filter_input (request .json , UPDATE_FILTER_FIELDS )
212- updated ['id' ] = id # use id from URL, regardless of what arrives in
214+ updated ['id' ] = docid # use id from URL, regardless of what arrives in
213215 # JSON payload
214216
215217 changing_permissions = (
@@ -238,9 +240,9 @@ def update_annotation(id):
238240
239241
240242# DELETE
241- @store .route ('/annotations/<id >' , methods = ['DELETE' ])
242- def delete_annotation (id ):
243- annotation = g .annotation_class .fetch (id )
243+ @store .route ('/annotations/<docid >' , methods = ['DELETE' ])
244+ def delete_annotation (docid ):
245+ annotation = g .annotation_class .fetch (docid )
244246
245247 if not annotation :
246248 return jsonify ('Annotation not found. No delete performed.' ,
0 commit comments