本文整理汇总了Python中hypermap.aggregator.models.Service.save方法的典型用法代码示例。如果您正苦于以下问题:Python Service.save方法的具体用法?Python Service.save怎么用?Python Service.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hypermap.aggregator.models.Service
的用法示例。
在下文中一共展示了Service.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def setUp(self):
signals.post_save.disconnect(layer_post_save, sender=Layer)
signals.post_save.disconnect(service_post_save, sender=Service)
for s in range(0, SERVICE_NUMBER):
service = Service(
url='http://%s.fakeurl.com' % s,
title='Title %s' % s,
type='OGC:WMS',
)
service.save()
for l in range(0, LAYER_PER_SERVICE_NUMBER):
layer = Layer(
name='Layer %s, from service %s' % (l, s),
bbox_x0=-179,
bbox_x1=179,
bbox_y0=-89,
bbox_y1=89,
service=service
)
layer.save()
service.layer_set.add(layer)
for c in range(0, TIMES_TO_CHECK):
for s in range(0, SERVICE_NUMBER):
service = Service.objects.all()[s]
service.check_available()
for layer in service.layer_set.all():
layer.check_available()
示例2: test_create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def test_create_wms_service(self):
# create the service
service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
)
service.save()
# check layer number
self.assertEqual(service.layer_set.all().count(), 9)
# check layer 0 (public)
layer_0 = service.layer_set.all()[0]
self.assertEqual(layer_0.name, 'geonode:_30river_project1_1')
self.assertEqual(layer_0.title, 'Rivers')
self.assertTrue(layer_0.is_public)
self.assertEqual(layer_0.keywords.all().count(), 3)
self.assertEqual(layer_0.service.srs.all().count(), 2)
self.assertEqual(layer_0.check_set.all().count(), 1)
# TODO test layer_0.layerdate_set
# test that if creating the service and is already exiting it is not being duplicated
# create the service
def create_duplicated_service():
duplicated_service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
)
duplicated_service.save()
self.assertRaises(Exception, create_duplicated_service)
示例3: create_wm_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_wm_service():
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
service = Service(
type='Hypermap:WorldMap',
catalog=catalog
)
service.save()
示例4: test_create_warper_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def test_create_warper_service(self):
# apparently signals are disconnected when running this test
# TODO figure out which test is disconnecting them without reconnecting
from django.db.models import signals
from hypermap.aggregator.models import Layer
from hypermap.aggregator.models import layer_post_save, service_post_save
signals.post_save.connect(layer_post_save, sender=Layer)
signals.post_save.connect(service_post_save, sender=Service)
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
# create the service
service = Service(
type='Hypermap:WARPER',
url='http://warper.example.com/warper/maps',
catalog=catalog
)
service.save()
# check layer number
self.assertEqual(service.layer_set.all().count(), 15)
# check layer name 29568 (public)
layer_0 = service.layer_set.get(name='29568')
self.assertEqual(layer_0.name, '29568')
self.assertEqual(layer_0.title, 'Plate 24: Map bounded by Myrtle Avenue')
self.assertTrue(layer_0.is_public)
self.assertEqual(layer_0.keywords.all().count(), 0)
self.assertEqual(layer_0.service.srs.all().count(), 3)
self.assertEqual(layer_0.check_set.all().count(), 1)
self.assertEqual(layer_0.layerdate_set.all()[0].date, '1855-01-01')
# a layer with no bbox must be stored with None coordinates
layer_no_bbox = service.layer_set.get(name='16239')
self.assertEqual(layer_no_bbox.bbox_x0, None)
self.assertEqual(layer_no_bbox.bbox_y0, None)
self.assertEqual(layer_no_bbox.bbox_x1, None)
self.assertEqual(layer_no_bbox.bbox_y1, None)
# test that if creating the service and is already exiting it is not being duplicated
# create the service
def create_duplicated_service():
duplicated_service = Service(
type='Hypermap:WARPER',
url='http://warper.example.com/warper/maps',
)
duplicated_service.save()
self.assertRaises(Exception, create_duplicated_service)
示例5: create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_wms_service():
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows111?',
catalog=Catalog.objects.get()
)
service.save()
示例6: create_warper_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_warper_service():
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
service = Service(
type='Hypermap:WARPER',
url='http://warper.example.com/warper/maps',
catalog=catalog
)
service.save()
示例7: _insert_or_update
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def _insert_or_update(self, resourcetype, source, mode='insert'):
''' Insert or update a record in the repository '''
try:
s = Service(type=HYPERMAP_SERVICE_TYPES[resourcetype], url=source)
s.save()
except Exception as err:
raise RuntimeError('HHypermap error: %s' % err)
# return a list of ids that were inserted or updated
ids = []
for res in Service.objects.filter(url=source).all():
ids.append({'identifier': res.id_string, 'title': res.title})
return ids
示例8: test_create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def test_create_wms_service(self):
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
# create the service
service = Service(
type='Hypermap:WARPER',
url='http://warper.example.com/warper/maps',
catalog=catalog
)
service.save()
# check layer number
self.assertEqual(service.layer_set.all().count(), 15)
# check layer name 29568 (public)
layer_0 = service.layer_set.get(name='29568')
self.assertEqual(layer_0.name, '29568')
self.assertEqual(layer_0.title, 'Plate 24: Map bounded by Myrtle Avenue')
self.assertTrue(layer_0.is_public)
self.assertEqual(layer_0.keywords.all().count(), 0)
self.assertEqual(layer_0.service.srs.all().count(), 3)
self.assertEqual(layer_0.check_set.all().count(), 1)
self.assertEqual(layer_0.layerdate_set.all()[0].date, '1855-01-01')
# a layer with no bbox must be stored with None coordinates
layer_no_bbox = service.layer_set.get(name='16239')
self.assertEqual(layer_no_bbox.bbox_x0, None)
self.assertEqual(layer_no_bbox.bbox_y0, None)
self.assertEqual(layer_no_bbox.bbox_x1, None)
self.assertEqual(layer_no_bbox.bbox_y1, None)
# test that if creating the service and is already exiting it is not being duplicated
# create the service
def create_duplicated_service():
duplicated_service = Service(
type='Hypermap:WARPER',
url='http://warper.example.com/warper/maps',
)
duplicated_service.save()
self.assertRaises(Exception, create_duplicated_service)
示例9: setUp
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def setUp(self):
signals.post_save.disconnect(layer_post_save, sender=Layer)
signals.post_save.disconnect(service_post_save, sender=Service)
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
for s in range(0, SERVICE_NUMBER):
service = Service(
url='http://%s.fakeurl.com' % s,
title='Title %s' % s,
type='OGC:WMS',
catalog=catalog
)
service.save()
for l in range(0, LAYER_PER_SERVICE_NUMBER):
layer = Layer(
name='Layer %s, from service %s' % (l, s),
bbox_x0=-179,
bbox_x1=179,
bbox_y0=-89,
bbox_y1=89,
service=service,
catalog=service.catalog
)
layer.save()
service.layer_set.add(layer)
for c in range(0, TIMES_TO_CHECK):
for s in range(0, SERVICE_NUMBER):
service = Service.objects.all()[s]
service.check_available()
for layer in service.layer_set.all():
layer.check_available()
示例10: test_create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def test_create_wms_service(self):
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
# create the service
service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows-invalid?',
catalog=catalog
)
service.save()
service.refresh_from_db()
# check service is invalid
self.assertEqual(service.is_valid, False)
# check layers number
self.assertEqual(service.layer_set.all().count(), 3)
# check all layers are invalid
for layer in service.layer_set.all():
self.assertEqual(layer.is_valid, False)
示例11: test_create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def test_create_wms_service(self):
catalog, created = Catalog.objects.get_or_create(
name="hypermap", slug="hypermap",
url="search_api"
)
# create the service
service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
catalog=catalog
)
service.save()
# check layer number
self.assertEqual(service.layer_set.all().count(), 9)
# check layer geonode:_30river_project1_1 (public)
layer_0 = service.layer_set.get(name='geonode:_30river_project1_1')
self.assertEqual(layer_0.title, 'Rivers')
self.assertTrue(layer_0.is_public)
self.assertEqual(layer_0.keywords.all().count(), 3)
self.assertEqual(layer_0.service.srs.all().count(), 2)
self.assertEqual(layer_0.check_set.all().count(), 1)
# TODO test layer_0.layerdate_set
# test that if creating the service and is already exiting it is not being duplicated
# create the service
def create_duplicated_service():
duplicated_service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
)
duplicated_service.save()
self.assertRaises(Exception, create_duplicated_service)
示例12: create_duplicated_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_duplicated_service():
duplicated_service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
)
duplicated_service.save()
示例13: setUp
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def setUp(self):
signals.post_save.disconnect(layer_post_save, sender=Layer)
signals.post_save.disconnect(service_post_save, sender=Service)
catalog_test_slug = "hypermap"
if SEARCH_TYPE == SEARCH_TYPE_SOLR:
self.solr = SolrHypermap()
# delete solr documents
# add the schema
print '> updating schema'.format(SEARCH_URL)
self.solr.update_schema(catalog=catalog_test_slug)
print '> clearing SEARCH_URL={0}'.format(SEARCH_URL)
self.solr.clear_solr(catalog=catalog_test_slug)
self.search_engine_endpoint = '{0}/solr/{1}/select'.format(
SEARCH_URL, catalog_test_slug
)
elif SEARCH_TYPE == SEARCH_TYPE_ES:
es = ESHypermap()
# delete ES documents
es.clear_es()
self.search_engine_endpoint = '{0}/{1}/_search'.format(
SEARCH_URL, catalog_test_slug
)
else:
raise Exception("SEARCH_TYPE not valid=%s" % SEARCH_TYPE)
catalog, created = Catalog.objects.get_or_create(
name=catalog_test_slug
)
service = Service(
url='http://fakeurl.com',
title='Title',
type='OGC:WMS',
catalog=catalog
)
service.save()
layer = Layer(
name='Layer 1',
bbox_x0=-40.0,
bbox_x1=-20.0,
bbox_y0=-40.0,
bbox_y1=-20.0,
service=service,
catalog=catalog
)
layer.title = layer.name
layer.save()
layer.created = datetime.datetime(2000, 3, 1, 0, 0, 0)
layer.save()
service.layer_set.add(layer)
layer = Layer(
name='Layer 2',
bbox_x0=-40.0,
bbox_x1=-20.0,
bbox_y0=20.0,
bbox_y1=40.0,
service=service,
catalog=catalog
)
layer.title = layer.name
layer.save()
layer.created = datetime.datetime(2001, 3, 1, 0, 0, 0)
layer.save()
service.layer_set.add(layer)
layer = Layer(
name='Layer 3',
bbox_x0=20.0,
bbox_x1=40.0,
bbox_y0=20.0,
bbox_y1=40.0,
service=service,
catalog=catalog
)
layer.title = layer.name
layer.save()
layer.created = datetime.datetime(2002, 3, 1, 0, 0, 0)
layer.save()
service.layer_set.add(layer)
layer = Layer(
name='Layer 4',
bbox_x0=20.0,
bbox_x1=40.0,
bbox_y0=-40.0,
bbox_y1=-20.0,
service=service,
catalog=catalog
)
layer.title = layer.name
layer.save()
layer.created = datetime.datetime(2003, 3, 1, 0, 0, 0)
layer.save()
service.layer_set.add(layer)
#.........这里部分代码省略.........
示例14: create_wms_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_wms_service():
service = Service(
type='OGC:WMS',
url='http://wms.example.com/ows?',
)
service.save()
示例15: create_duplicated_service
# 需要导入模块: from hypermap.aggregator.models import Service [as 别名]
# 或者: from hypermap.aggregator.models.Service import save [as 别名]
def create_duplicated_service():
duplicated_service = Service(
type='Hypermap:WorldMap',
url='http://worldmap.harvard.edu/'
)
duplicated_service.save()