コード例 #1
0
ファイル: tests.py プロジェクト: Niran814804102/cga-worldmap
 def test_get_gazetteer_entry(self):
     if settings.USE_GAZETTEER:
         results = getGazetteerEntry(5)
         self.assertEquals(1, len(results))
         entry = results[0]
         self.assertEquals(5, entry["id"])
         self.assertEquals("Paradise5", entry["placename"])
コード例 #2
0
ファイル: tests.py プロジェクト: geraldstanje/cga-worldmap
 def test_get_gazetteer_entry(self):
     if settings.USE_GAZETTEER:
         results = getGazetteerEntry(5)
         self.assertEquals(1, len(results))
         entry = results[0]
         self.assertEquals(5, entry["id"])
         self.assertEquals("Paradise5", entry["placename"])
コード例 #3
0
ファイル: handlers.py プロジェクト: mbertrand/cga-worldmap
 def read(self, request, place_name, map = None, layer = None, start_date = None, end_date = None, project=None, services=None):
     if place_name.isdigit():
         posts = getGazetteerEntry(place_name)
     else:
         posts = getGazetteerResults(place_name, map, layer, start_date, end_date, project)
     if services is not None:
         posts.extend(getExternalServiceResults(place_name,services))
     return posts
コード例 #4
0
ファイル: handlers.py プロジェクト: raprasad/cga-worldmap
 def read(self, request, place_name, map = None, layer = None, start_date = None, end_date = None, project=None, services=None):
     if place_name.isdigit():
         posts = getGazetteerEntry(place_name)
     else:
         posts = getGazetteerResults(place_name, map, layer, start_date, end_date, project)
     if services is not None:
         posts.extend(getExternalServiceResults(place_name,services))
     return posts
コード例 #5
0
def search(request, place_name, map=None, layer=None, start_date=None, end_date=None, project=None, services=None, user=None, format='json'):
    """
    Search the Gazetteer and return results in JSON or XML format.
    """
    if not format:
        out_format = 'json'
    else:
        out_format = format.lower()
    if out_format not in ('xml', 'json'):
        out_format = 'json'

    if place_name.isdigit():
        posts = getGazetteerEntry(place_name)
    else:
        posts = getGazetteerResults(place_name, map, layer, start_date, end_date, project, user)
    if services is not None:
        posts.extend(getExternalServiceResults(place_name, services))
    if out_format == 'json':
        return HttpResponse(json.dumps(posts, sort_keys=True, indent=4),
                            content_type="application/json")
    elif out_format == 'xml':
        return HttpResponse(dicttoxml([{'resource': post} for post in posts], attr_type=False, custom_root='response'),
                            content_type="application/xml")