def get_environment(request): '''Returns an Gnome Environment object in JSON.''' content_requested = request.matchdict.get('obj_id') resp = Response(content_type='arraybuffer') route = content_requested[1] if len(content_requested) > 1 else None if (len(content_requested) > 1): if route == 'grid': resp.body = get_grid(request) resp.headers.add('content-encoding', 'deflate') return cors_response(request, resp) if route == 'vectors': resp.body, dshape = get_vector_data(request) resp.headers.add('content-encoding', 'deflate') resp.headers.add('Access-Control-Expose-Headers', 'shape') resp.headers.add('shape', str(dshape)) return cors_response(request, resp) if route == 'nodes': resp.body = get_nodes(request) resp.headers.add('content-encoding', 'deflate') return cors_response(request, resp) if route == 'centers': resp.body = get_centers(request) resp.headers.add('content-encoding', 'deflate') return cors_response(request, resp) if route == 'metadata': return get_metadata(request) else: return get_object(request, implemented_types)
def get_model(request): ''' Returns Model object in JSON. - This method varies slightly from the common object method in that if we don't specify a model ID, we: - return the current active model if it exists or... - return the specification. ''' ret = None obj_id = obj_id_from_url(request) session_lock = acquire_session_lock(request) log.info(' session lock acquired (sess:{}, thr_id: {})'.format( id(session_lock), current_thread().ident)) try: if obj_id is None: my_model = get_active_model(request) if my_model is not None: ret = my_model.serialize(options=web_ser_opts) if ret is None: ret = get_object(request, implemented_types) finally: session_lock.release() log.info(' session lock released (sess:{}, thr_id: {})'.format( id(session_lock), current_thread().ident)) return ret
def get_map(request): '''Returns a Gnome Map object in JSON.''' obj_ids = request.matchdict.get('obj_id') if (len(obj_ids) >= 2 and obj_ids[1] == 'geojson'): return get_geojson(request, implemented_types) else: return get_object(request, implemented_types)
def get_mover(request): content_requested = request.matchdict.get('obj_id') if (len(content_requested) > 1 and content_requested[1] == 'grid'): return get_current_info(request) elif (len(content_requested) > 1 and content_requested[1] == 'centers'): return get_grid_centers(request) else: return get_object(request, implemented_types)
def get_map(request): '''Returns a Gnome Map object in JSON.''' content_requested = request.matchdict.get('obj_id') resp = Response(content_type='arraybuffer', content_encoding='deflate') route = content_requested[1] if len(content_requested) > 1 else None if (len(content_requested) > 1): if route == 'raster': resp.body, shape, bbox = get_raster(request) resp.headers.add('Access-Control-Expose-Headers', 'shape') resp.headers.add('Access-Control-Expose-Headers', 'bbox') resp.headers.add('shape', str(shape)) resp.headers.add('bbox', str(bbox)) return cors_response(request, resp) if route == 'geojson': return get_geojson(request, implemented_types) else: return get_object(request, implemented_types)
def get_release(request): '''Returns an Gnome Release object in JSON.''' content_requested = request.matchdict.get('obj_id') resp = Response(content_type='arraybuffer', content_encoding='deflate') route = content_requested[1] if len(content_requested) > 1 else None if (len(content_requested) > 1): if route == 'start_positions': resp.body = get_start_positions(request) return cors_response(request, resp) if route == 'polygons': resp.body, num_lengths = get_polygons(request) resp.headers.add('Access-Control-Expose-Headers', 'num_lengths') resp.headers.add('num_lengths', str(num_lengths)) return cors_response(request, resp) if route == 'metadata': return get_metadata(request) else: return get_object(request, implemented_types)
def get_distribution(request): '''Returns a Gnome Distribution object in JSON.''' return get_object(request, implemented_types)
def get_appearance(request): '''Returns a Gnome appearance object in JSON.''' return get_object(request, implemented_types)
def get_initializer(request): '''Returns a Gnome Initializer object in JSON.''' return get_object(request, implemented_types)
def get_element_type(request): '''Returns a Gnome ElementType object in JSON.''' return get_object(request, implemented_types)
def get_outputter(request): '''Returns a Gnome Outputter object in JSON.''' return get_object(request, implemented_types)
def get_environment(request): '''Returns an Gnome Environment object in JSON.''' return get_object(request, implemented_types)
def get_spill(request): '''Returns a Gnome Spill object in JSON.''' return get_object(request, implemented_types)
def get_map(request): '''Returns a Gnome Map object in JSON.''' return get_object(request, implemented_types)
def get_mover(request): """Returns an Gnome Environment object in JSON.""" return get_object(request, implemented_types)
def get_release(request): '''Returns a Gnome Release object in JSON.''' return get_object(request, implemented_types)
def get_weatherer(request): '''Returns a Gnome Weatherer object in JSON.''' return get_object(request, implemented_types)
def get_substance(request): '''Returns a Gnome Substance object in JSON.''' return get_object(request, implemented_types)