def on_get(self, req, resp, doc_id, **kwargs): try: result = Result.from_id(doc_id) except ValueError: raise falcon.HTTPNotFound() else: self.json(req, resp, result.format())
def get(self, doc_id): try: result = Result.from_id(doc_id) except ValueError: raise NotFound() else: return self.json(result.to_geojson())
def on_get(self, req, resp, doc_id, **kwargs): try: result = Result.from_id(doc_id) except ValueError: raise falcon.HTTPNotFound() else: self.json(req, resp, result.format())
def follow_successor(helper, result): if result.successors: id = result.successors try: successor = Result.from_id(id) except ValueError: # https://github.com/addok/addok-geozones/issues/1 print('Unable to find successor {0.successors} from id ' '{0._id}'.format(result)) return # Sometimes name does not change (merge). if successor.name != result.name: result.labels = ['{} (anciennement {})'.format( successor.name, result.name)] result._cache = {} result._doc = successor._doc
def test_from_id(factory): factory(name="avenue de Paris", type="street", id="123") doc = Result.from_id("123") assert doc.id == "123"
def test_from_id(factory): doc = factory(name="avenue de Paris", type="street", id="123") result = Result.from_id(doc['_id']) assert result.id == "123"