def georeferenceGetProcess(request): log.info('Receive request GetGeoreferenceProcess') try: request_data = None if request.method == 'POST': request_data = request.json_body if 'georeferenceid' in request_data: georeferenceid = int(request_data['georeferenceid']) log.debug('Parsed parameters - georeferenceid: %s'%georeferenceid) mapObj = Map.by_id(int(Georeferenzierungsprozess.by_id(georeferenceid, request.db).mapid), request.db) response = createResponseForSpecificGeoreferenceProcess(mapObj, request, georeferenceid) elif 'objectid' in request_data: mapObjId = request_data['objectid'] log.debug('Parsed parameters - mapid: %s'%mapObjId) mapObj = Map.by_id(int(mapObjId), request.db) response = createGeneralResponse(mapObj, request) else: log.error('Could not find a georeferenceid or and objectid in the post request parameters ...') raise GeoreferenceParameterError return response except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except ProcessIsInvalideException as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest('This georeference process is blocked for further work!') except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def getGeoreferencePage(request): log.info('Call view getGeoreferencePage.') if 'id' in request.params: return {'objectid':request.params['id']} elif 'georeferenceid' in request.params: georefProcess = Georeferenzierungsprozess.by_id(request.params['georeferenceid'], request.db) return {'objectid':georefProcess.mapid}
def getTimestampsForId(request): """ Returns a json document which contains a a list of messtischblatt tuples which have the same blattnumber like the given object. """ try: log.info('Receive request for timestamps for a given object number.') dbsession = request.db object_id = request.GET.get('id') metadataObj = Metadata.by_id(object_id, dbsession) spatial_relation_objects = VBlattschnittMtb.allForBlattnr( metadataObj.blattnr, dbsession) #create response response = [] for rel_object in spatial_relation_objects: if rel_object.isttransformiert: response.append({ 'id': rel_object.mapid, 'time': rel_object.time, 'extent': Map.getExtent(rel_object.map, dbsession, DATABASE_SRID) }) return {'maps': response} except DBAPIError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def georeferenceGetProcess(request): log.info('Receive request GetGeoreferenceProcess') try: request_data = None if request.method == 'POST': request_data = request.json_body objectid = None if 'objectid' in request_data: validateId(request_data['objectid']) objectid = int(request_data['objectid']) log.debug('Objectid is valide: %s'%request_data) georeferenceid = None if 'georeferenceid' in request_data: georeferenceid = int(request_data['georeferenceid']) if georeferenceid: response = createResponseForSpecificGeoreferenceProcess(objectid, georeferenceid, request) else: response = createGeneralResponse(objectid, request) return json.dumps(response, ensure_ascii=False, encoding='utf-8') except GeoreferenceParameterError as e: message = 'Wrong or missing service parameter - %s'%e.value log.error(message) return HTTPBadRequest(message) except Exception as e: message = 'Problems while creating response for getprocess request - %s'%e log.error(message) return HTTPInternalServerError(message)
def __call__(self): log.info("Start processing georeference confirmation request.") try: # parse query parameter and check if they are valide self.__parseQueryParameter__() self.__parseUserId__() # initialize georef process dbsession = self.request.db georeferenceProcess = createGeoreferenceProcess(self.mtbid, dbsession, tmp_dir, log) if hasattr(self, 'georefid'): self.__validateQueryParameterWithGeorefId__() return self.__confirmExistingGeorefProcess__(self.georefid, georeferenceProcess) elif not hasattr(self, 'georefid'): self.__validateQueryParameterWithoutGeorefId__() return self.__registerNewConfirmedGeorefProcess__(georeferenceProcess) else: # error handling log.error("Error while processing georeference confirmation request!") raise except GeoreferenceParameterError as e: log.error('Wrong or missing service parameter - %s'%e) return HTTPBadRequest('Wrong or missing service parameter') except Exception as e: log.error('Problems while computing validation result - %s'%e) return HTTPInternalServerError('Problems while computing validation result')
def georeferenceGetProcess(request): log.info('Receive request GetGeoreferenceProcess') try: request_data = None if request.method == 'POST': request_data = request.json_body objectid = None if 'objectid' in request_data: validateId(request_data['objectid']) objectid = int(request_data['objectid']) log.debug('Objectid is valide: %s' % request_data) georeferenceid = None if 'georeferenceid' in request_data: georeferenceid = int(request_data['georeferenceid']) if georeferenceid: response = createResponseForSpecificGeoreferenceProcess( objectid, georeferenceid, request) else: response = createGeneralResponse(objectid, request) return json.dumps(response, ensure_ascii=False, encoding='utf-8') except GeoreferenceParameterError as e: message = 'Wrong or missing service parameter - %s' % e.value log.error(message) return HTTPBadRequest(message) except Exception as e: message = 'Problems while creating response for getprocess request - %s' % e log.error(message) return HTTPInternalServerError(message)
def getTimestampsForId(request): """ Returns a json document which contains a a list of messtischblatt tuples which have the same blattnumber like the given object. """ try: log.info('Receive request for timestamps for a given object number.') dbsession = request.db object_id = request.GET.get('id') object = Messtischblatt.by_id(object_id, dbsession) spatial_relation_objects = Messtischblatt.allForBlattnr( object.blattnr, dbsession) response = [] for rel_object in spatial_relation_objects: if rel_object.isttransformiert: time = MdZeit.by_id(rel_object.id, dbsession).datierung response.append({ 'id': rel_object.id, 'time': time, 'extent': Messtischblatt.getExtent(rel_object.id, dbsession) }) return json.dumps({'maps': response}, ensure_ascii=False, encoding='utf-8') except DBAPIError: return Response(conn_err_msg, content_type='text/plain', status_int=500)
def getPage_profileMtb(request): try: messtischblatt_id = None if 'id' in request.params: messtischblatt_id = request.params['id'] log.info('Receive get profile mtb page for id %s.' % messtischblatt_id) messtischblatt = Messtischblatt.by_id(messtischblatt_id, request.db) user_id = authenticated_userid(request) if user_id: groups = groupfinder(user_id, request) if groups and 'g:moderator' in groups or 'g:admin' in groups: return { 'with_modify': True, 'zoomify_prop': messtischblatt.zoomify_properties, 'zoomify_width': messtischblatt.zoomify_width, 'zoomify_height': messtischblatt.zoomify_height, 'key': messtischblatt.dateiname } return { 'zoomify_prop': messtischblatt.zoomify_properties, 'zoomify_width': messtischblatt.zoomify_width, 'zoomify_height': messtischblatt.zoomify_height, 'key': messtischblatt.dateiname } except: log.error( 'Internal server error while trying to get profile page. Please try again or contact the page administrator.' ) raise InternalAuthentificationError( 'Internal server error while trying to get profile page. Please try again or contact the page administrator.' )
def getPage_chooseGeorefMtb(request): log.info('Call view getPage_chooseGeorefMtb.') if 'blattnr' in request.params: paginator = getZoomifyCollectionForBlattnr(request, request.GET.get('blattnr'), request.db) return {'paginator':paginator} else: return {}
def getPage_profileMtb(request): try: messtischblatt_id = None if "objectid" in request.params: messtischblatt_id = request.params["objectid"] log.info("Receive get map profile page for id %s." % messtischblatt_id) georef = False if "georef" in request.params and request.params["georef"].lower() == "true": georef = True if georef: permalink = createPermalink(request, messtischblatt_id) return HTTPFound(location=permalink) messtischblatt = Messtischblatt.by_id(messtischblatt_id, request.db) metadata = MdCore.by_id(messtischblatt.id, request.db) metadata_datensatz = MdDatensatz.by_ObjectId(messtischblatt.id, request.db) return { "zoomify_prop": messtischblatt.zoomify_properties, "zoomify_width": messtischblatt.zoomify_width, "zoomify_height": messtischblatt.zoomify_height, "key": "vk20-md-%s" % messtischblatt.id, "titel_long": metadata.titel, "titel_short": metadata.titel_short, "permalink": metadata_datensatz.permalink, } except: log.error( "Internal server error while trying to get profile page. Please try again or contact the page administrator." ) raise InternalAuthentificationError( "Internal server error while trying to get profile page. Please try again or contact the page administrator." )
def publishGeorefParameters(request): log.info('Request - Publish georeference result.') try: log.debug('Parse parameters ...') objectid = request.params['objectid'] georeferenceid = request.params['georeferenceid'] messtischblatt = Messtischblatt.by_id(objectid, request.db) georeferenceprocess = Georeferenzierungsprozess.by_id( georeferenceid, request.db) log.debug('Udpate parameters') georeferenceprocess.publish = True messtischblatt.updated = False return json.dumps( { 'message': 'The georeference process is now published. The georeference map will soon be updated and than ready for accessing.' }, ensure_ascii=False, encoding='utf-8') except Exception as e: log.error( 'Error while trying to request georeference history information') log.error(e) return {}
def resetGeorefParameters(request): try: log.info('Receive a reset georeference parameter requests.') login = checkIsUser(request) dbsession = request.db messtischblatt_id = request.params['mtbid'] georeference_process = Georeferenzierungsprozess.by_messtischblattid(messtischblatt_id, dbsession) referenz = georeference_process.clipparameter fehlerbeschreibung = 'Zuruecksetzen von Georeferenzierungsparameter für GeorefId=%s'%georeference_process.id if login and messtischblatt_id and referenz and fehlerbeschreibung and Users.by_username(login, dbsession): log.debug('Save reset process in table fehlermeldungen ...') newFehlermeldung = Fehlermeldung(objektid = messtischblatt_id, referenz = referenz, nutzerid = login, fehlerbeschreibung = fehlerbeschreibung, timestamp = getTimestampAsPGStr()) dbsession.add(newFehlermeldung) log.debug('Remove georeference process ...') dbsession.delete(georeference_process) log.debug('Remove refmtblayer ...') try: refmtblayer = RefMtbLayer.by_id(MTB_LAYER_ID, messtischblatt_id, dbsession) dbsession.delete(refmtblayer) except: log.debug('No entry for refmtblayer found ...') pass log.debug('Update messtischblatt db ...') messtischblatt = Messtischblatt.by_id(messtischblatt_id, dbsession) messtischblatt.isttransformiert = False return json.dumps({'status':'confirmed'}, ensure_ascii=False, encoding='utf-8') except DBAPIError: log.error('Problems while trying to remove georeference parameter from the database ...') return Response(conn_err_msg, content_type='text/plain', status_int=500)
def georeference_profile_page(request): log.info('Request - Get georeference profile page.') dbsession = request.db userid = checkIsUser(request) user = Users.by_username(userid, dbsession) try: log.debug('Query georeference profile information from database for user %s'%userid) queryData = request.db.query(Georeferenzierungsprozess, Metadata, Map).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .join(Map, Georeferenzierungsprozess.mapid == Map.id)\ .filter(Georeferenzierungsprozess.nutzerid == userid)\ .order_by(desc(Georeferenzierungsprozess.id)) log.debug('Create response list') georef_profile = [] for record in queryData: georef = record[0] metadata = record[1] mapObj = record[2] boundingbox = Map.getBox2d(georef.mapid, dbsession, 900913) georef_profile.append({'georef_id':georef.id, 'mapid':georef.mapid, 'clip_params': georef.georefparams, 'time': metadata.timepublish, 'transformed': georef.processed, 'isvalide': georef.adminvalidation, 'titel': metadata.title, 'key': mapObj.apsdateiname, 'time_georef':georef.timestamp,'boundingbox':boundingbox[4:-1].replace(' ',','),'type':georef.type, 'published':georef.processed}) log.debug('Response: %s'%georef_profile) return {'georef_profile':georef_profile, 'points':user.bonuspunkte} except Exception as e: log.error('Error while trying to request georeference history information'); log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def __call__(self): log.info("Start processing georeference validation result.") try: # parse query parameter and check if they are valide self.__parseQueryParameter__() self.__validateQueryParameter__() self.__parseUserId__() # initialize georef process dbsession = self.request.db georeferenceProcess = createGeoreferenceProcess(self.mtbid, dbsession, tmp_dir, log) # create validation result and get destination path and georeference id validationResultPath = os.path.join(dest_mapfilefolder,georeferenceProcess.messtischblatt.dateiname+"::"+str(getUniqueId())+".tif") georefId, destPath = georeferenceProcess.fastGeoreference(self.userid,self.points,validationResultPath) # create mapfile for georeference result wms_url = createMapfile(georeferenceProcess.messtischblatt.dateiname, destPath, src_mapfilepath, dest_mapfilefolder, mapfileInitParameter) response = {'wms_url':wms_url,'layer_id':georeferenceProcess.messtischblatt.dateiname,'georefid':georefId} return json.dumps(response, ensure_ascii=False, encoding='utf-8') except GeoreferenceParameterError as e: message = 'Wrong or missing service parameter - %s'%e.value log.error(message) return HTTPBadRequest(message) except Exception as e: message = 'Problems while computing validation result - %s'%e.value log.error(message) return HTTPInternalServerError(message)
def getAdminEvaluationPage(request): log.info('Request - Get georeference profile page.') try: resultSet = request.db.execute(georeference_evaluation_query) log.debug('Create response list') georef_profile = [] for record in resultSet: encoded_clip_params = str( convertUnicodeDictToUtf(ast.literal_eval( record['clip_params']))).replace('\'', '"') georef_profile.append({ 'georef_id': record['georef_id'], 'mtb_id': record['mtbid'], 'clip_params': encoded_clip_params, 'time': record['time'], 'transformed': record['isttransformiert'], 'isvalide': record['isvalide'], 'titel': record['titel'], 'key': record['key'], 'time_georef': record['time_georef'], 'type': record['type'], 'userid': record['userid'], 'published': record['published'] }) log.debug('Response: %s' % georef_profile) return {'georef_profile': georef_profile} except Exception as e: log.error( 'Error while trying to request georeference history information') log.error(e) return {}
def georeference_profile_page(request): log.info('Request - Get georeference profile page.') dbsession = request.db userid = checkIsUser(request) user = Users.by_username(userid, dbsession) try: log.debug('Query georeference profile information from database for user %s'%userid) query_georefprocess = georeference_profile_query%userid resultSet = dbsession.execute(query_georefprocess) log.debug('Create response list') georef_profile = [] for record in resultSet: georef_profile.append({'georef_id':record['georef_id'], 'mtb_id':record['mtbid'], 'clip_params': record['clip_params'], 'time': record['time'], 'transformed': record['isttransformiert'], 'isvalide': record['isvalide'], 'titel': record['titel'], 'key': record['key'], 'time_georef':record['time_georef'],'boundingbox':record['box'][4:-1].replace(' ',','),'type':record['type'], 'published':record['published']}) log.debug('Response: %s'%georef_profile) return {'georef_profile':georef_profile, 'points':user.bonuspunkte} except Exception as e: log.error('Error while trying to request georeference history information'); log.error(e) return {}
def getPage_profileMtb(request): try: messtischblatt_id = None if 'objectid' in request.params: maps_id = request.params['objectid'] log.info('Receive get map profile page for id %s.'%messtischblatt_id) georef = False if 'georef' in request.params and request.params['georef'].lower() == 'true': georef = True if georef: permalink = createPermalink(request, maps_id) return HTTPFound(location=permalink) mapObj = Map.by_id(maps_id, request.db) metadata = Metadata.by_id(maps_id, request.db) oai = createOAI(mapObj.id) return {'zoomify':metadata.imagezoomify,'key':oai, 'titel_long': metadata.title,'titel_short': metadata.titleshort, 'permalink': metadata.apspermalink} except: log.error('Internal server error while trying to get profile page. Please try again or contact the page administrator.') log.error(traceback.format_exc()) raise InternalAuthentificationError('Internal server error while trying to get profile page. Please try again or contact the page administrator.')
def georeferenceUpdate(request): log.info('Receive request for processing georeference update result') try: userid = checkIsUser(request) request_data = None if request.method == 'POST': request_data = request.json_body mapObj = parseMapObjForId(request_data, 'id', request.db) log.debug('Id is valide: %s' % request_data) log.debug( 'Check if there exists a registered georeference process for this messtischblatt ...' ) if Georeferenzierungsprozess.isGeoreferenced(mapObj.id, request.db) == False: response = { 'text': 'There is no registered georeference process for this messtischblatt. Please move back to the confirm process.' } return response # actual only support this option if target srs is EPSG:4314 log.debug('Saving georeference process in the database ...') if request_data['georeference']: encoded_clip_params = convertUnicodeDictToUtf( request_data['georeference']) georefProcess = registerUpdateGeoreferenceProcessInDb( mapObj, userid, str(encoded_clip_params), request.db) log.debug('Create response ...') # right now the premise is that for the updated gcps are equal to the removed gcps. For every # updated gcps the users get new points achievement_points = len( request_data['georeference']['remove']['gcps']) * 5 response = { 'text': 'Georeference result updated. It will soon be ready for use.', 'georeferenceid': georefProcess.id, 'points': achievement_points, 'gcps': request_data['georeference']['new'], 'type': 'update' } return response else: log.error('The remove and new parameters are not valide - %s') raise GeoreferenceParameterError( 'The remove and new parameters are not valide.') except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def checkIsUser(request): userid = unauthenticated_userid(request) log.info('Checked userid is %s'%userid) if Users.by_username(userid, request.db): # this should return None if the user doesn't exist return userid else: return False
def checkIsUser(request): userid = unauthenticated_userid(request) log.info('Checked userid is %s' % userid) if Users.by_username(userid, request.db): # this should return None if the user doesn't exist return userid else: return False
def checkIsUser(request): userid = unauthenticated_userid(request) log.info('Checked userid is %s'%userid) if userid is not None: # this should return None if the user doesn't exist return userid else: return False
def getGeoreferencePage(request): log.info('Call view getGeoreferencePage.') if 'id' in request.params: return {'objectid': request.params['id']} elif 'georeferenceid' in request.params: georefProcess = Georeferenzierungsprozess.by_id( request.params['georeferenceid'], request.db) return {'objectid': georefProcess.mapid}
def georeference_profile_page(request): log.info('Request - Get georeference profile page.') dbsession = request.db userid = checkIsUser(request) user = Users.by_username(userid, dbsession) try: log.debug( 'Query georeference profile information from database for user %s' % userid) queryData = request.db.query(Georeferenzierungsprozess, Metadata, Map).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .join(Map, Georeferenzierungsprozess.mapid == Map.id)\ .filter(Georeferenzierungsprozess.nutzerid == userid)\ .order_by(desc(Georeferenzierungsprozess.id)) log.debug('Create response list') georef_profile = [] for record in queryData: georef = record[0] metadata = record[1] mapObj = record[2] boundingbox = Map.getBox2d(georef.mapid, dbsession, 900913) georef_profile.append({ 'georef_id': georef.id, 'mapid': georef.mapid, 'clip_params': georef.georefparams, 'time': metadata.timepublish, 'transformed': georef.processed, 'isvalide': georef.adminvalidation, 'titel': metadata.title, 'key': mapObj.apsdateiname, 'time_georef': georef.timestamp, 'boundingbox': boundingbox[4:-1].replace(' ', ','), 'type': georef.type, 'published': georef.processed }) log.debug('Response: %s' % georef_profile) return {'georef_profile': georef_profile, 'points': user.bonuspunkte} except Exception as e: log.error( 'Error while trying to request georeference history information') log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def getPermalinkForObjectid(request): """ Contains a permalink url for the given objectid""" try: log.info('Receive get permalink request.') objectid = request.GET.get('objectid') permalink = createPermalink(request, objectid) return Response(permalink, content_type='text/plain') except DBAPIError: return Response(conn_err_msg, content_type='text/plain', status_int=500)
def getPage_chooseGeorefMtb(request): log.info('Call view getPage_chooseGeorefMtb.') if 'blattnr' in request.params: paginator = getZoomifyCollectionForBlattnr(request, request.GET.get('blattnr'), request.db) return {'paginator': paginator} else: return {}
def set_locale_cookie(request): if request.GET['language']: language = request.GET['language'] log.info('Dispatch change locales request for language %s'%language) if not language in LOCALES: language = request.registry.settings.default_locale_name response = Response() response.set_cookie('_LOCALE_', value=language, max_age=31536000) target_url = request.route_url('home', _query={'welcomepage':'off'}) return HTTPFound(location = target_url, headers = response.headers)
def set_locale_cookie(request): if request.GET['language']: language = request.GET['language'] log.info('Dispatch change locales request for language %s' % language) if not language in LOCALES: language = request.registry.settings.default_locale_name response = Response() response.set_cookie('_LOCALE_', value=language, max_age=31536000) target_url = request.route_url('home', _query={'welcomepage': 'off'}) return HTTPFound(location=target_url, headers=response.headers)
def getPermalinkForObjectidv2(request): """ Contains a permalink url for the given objectid""" try: log.info('Receive get permalink request.') objectid = request.GET.get('objectid') dbsession = request.db centroid = Map.getCentroid_byApsObjectid(objectid, dbsession, 900913) mapid = Map.by_apsObjectId(objectid, dbsession).id return HTTPFound(location=request.host_url + '/vkviewer/?welcomepage=off&z=5&c=%s,%s&oid=%s'%(centroid[0],centroid[1],mapid)) except DBAPIError: log.error(traceback.format_exc()) raise HTTPBadRequest(GENERAL_ERROR_MESSAGE)
def georeference_profile_page(request): log.info('Request - Get georeference profile page.') dbsession = request.db userid = checkIsUser(request) user = Users.by_username(userid, dbsession) try: log.debug( 'Query georeference profile information from database for user %s' % userid) query_georefprocess = georeference_profile_query % userid resultSet = dbsession.execute(query_georefprocess) log.debug('Create response list') georef_profile = [] for record in resultSet: georef_profile.append({ 'georef_id': record['georef_id'], 'mtb_id': record['mtbid'], 'clip_params': record['clip_params'], 'time': record['time'], 'transformed': record['isttransformiert'], 'isvalide': record['isvalide'], 'titel': record['titel'], 'key': record['key'], 'time_georef': record['time_georef'], 'boundingbox': record['box'][4:-1].replace(' ', ','), 'type': record['type'], 'published': record['published'] }) log.debug('Response: %s' % georef_profile) return {'georef_profile': georef_profile, 'points': user.bonuspunkte} except Exception as e: log.error( 'Error while trying to request georeference history information') log.error(e) return {}
def logContactRequest(request): try: log.info('Receive a contact message request.') # check if there is a userid from a registered user userid = checkIsUser(request) if not userid: userid = 'anonym' if 'reference' in request.params: reference = request.params['reference'] if 'message' in request.params: message = request.params['message'] if 'email' in request.params: email = request.params['email'] # check if the input parameters are valide log.debug('Validate the query parameters ...') if not email or not reference or not message: raise MissingQueryParameterError('Missing query parameter ...') if len(message) <= 5: raise WrongParameterException('Message is to short. For a correct understanding of your matter please leave us a short explanation.') # log into database log.debug('Save contact message in the database ...') fehlermeldung = Fehlermeldung(email = email, referenz = reference, nutzerid = userid, fehlerbeschreibung = message, timestamp = getTimestampAsPGStr()) request.db.add(fehlermeldung) # sending an email log.debug('Instruct admin about new contact message ...'); reportErrorMessageToAdmin(fehlermeldung, 'Request - Contact form', userid) log.debug('Create response message ...') return {'status':'confirmed'} except MissingQueryParameterError: log.error('Could not create correct error report because of missing query parameters.') log.error(traceback.format_exc()) raise HTTPBadRequest('Missing form parameters') except WrongParameterException as e: log.error(e.msg) log.error(traceback.format_exc()) raise HTTPBadRequest('Wrong form parameters') except DBAPIError: log.error('Problems while trying to register report error in database') log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE) except Exception: log.error('Unknown error while trying to process a contact message request ...') log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def georeferenceUpdate(request): log.info('Receive request for processing georeference update result') try: userid = checkIsUser(request) request_data = None if request.method == 'POST': request_data = request.json_body if request_data: validateId(request_data['id']) log.debug('Request data is valide: %s'%request_data) log.debug('Check if there exists a registered georeference process for this messtischblatt ...') messtischblatt = Messtischblatt.by_id(request_data['id'], request.db) isAlreadyGeorefProcess = Georeferenzierungsprozess.by_messtischblattid(messtischblatt.id, request.db) if isAlreadyGeorefProcess is None: response = {'text':'There is no registered georeference process for this messtischblatt. Please move back to the confirm process.'} return json.dumps(response, ensure_ascii=False, encoding='utf-8') # actual only support this option if target srs is EPSG:4314 log.debug('Saving georeference process in the database ...') if request_data['georeference']: encoded_clip_params = convertUnicodeDictToUtf(request_data['georeference']) georefProcess = registerNewGeoreferenceProcessInDb(messtischblatt.id, userid, str(encoded_clip_params), 'update', request.db) log.debug('Set update status for messtischblatt ...') messtischblatt.setIsUpdated(True) log.debug('Create response ...') # right now the premise is that for the updated gcps are equal to the removed gcps. For every # updated gcps the users get new points achievement_points = len(request_data['georeference']['remove']['gcps'])*5 #gcps = getJsonDictPasspointsForMapObject(messtischblatt.id, request.db) response = {'text':'Georeference result updated. It will soon be ready for use.','georeferenceid':georefProcess.id, 'points':achievement_points, 'gcps':request_data['georeference']['new'] ,'type':'update'} return json.dumps(response, ensure_ascii=False, encoding='utf-8') else: log.error('The remove and new parameters are not valide - %s') raise GeoreferenceParameterError('The remove and new parameters are not valide.') except GeoreferenceParameterError as e: message = 'Wrong or missing service parameter - %s'%e.value log.error(message) return HTTPBadRequest(message) except Exception as e: message = 'Problems while computing validation result - %s'%e log.error(message) return HTTPInternalServerError(message)
def georeferenceConfirm(request): log.info('Receive request for processing georeference validation result') try: userid = checkIsUser(request) request_data = None if request.method == 'POST': request_data = request.json_body mapObj = parseMapObjForId(request_data, 'id', request.db) log.debug('Id is valide: %s'%request_data) log.debug('Check if there is already a registered georeference process for this messtischblatt ...') if Georeferenzierungsprozess.isGeoreferenced(mapObj.id, request.db): msg = 'There is already a georeference process for this process. Please load again and start on the latest changes.' log.debug(msg) georeferenceid = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(mapObj.id, request.db).id response = {'text':msg,'georeferenceid':georeferenceid} return response # actual only support this option if target srs is EPSG:4314 log.debug('Start saving georeference process in the database ...') epsg_code = int(str(request_data['georeference']['target']).split(':')[1]) if request_data['georeference']['source'] == 'pixel' and epsg_code == 4314: log.debug('Create georeference process record ...') timestamp = getTimestampAsPGStr() georeference_parameter = str(convertUnicodeDictToUtf(request_data['georeference'])) georefProcess = Georeferenzierungsprozess(messtischblattid = mapObj.apsobjectid, nutzerid = userid, georefparams = ast.literal_eval(georeference_parameter), clipparameter = georeference_parameter, timestamp = timestamp, isactive = True, type = 'new', adminvalidation = '', processed = False, mapid = mapObj.id, overwrites = 0) request.db.add(georefProcess) request.db.flush() log.debug('Create response ...') response = {'text':'Georeference result saved. It will soon be ready for use.','georeferenceid':georefProcess.id, 'points':20, 'gcps':request_data['georeference'] ,'type':'confirm'} return response else: raise GeoreferenceParameterError('Wrong or missing service parameter') except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def getMainPage(request): log.info('Call view get_index_page.') # checks if already a user cookie is set and if yes gives back the logged in view userid = checkIsUser(request) if userid: if ('z' in request.params and 'c' in request.params and 'oid' in request.params) or 'georef' in request.params: return HTTPFound(location = request.route_url('home_login', _query=appendParameterToQueryDict(request))) return HTTPFound(location = request.route_url('home_login', _query=appendParameterToQueryDict(request, 'georef', 'on'))) if not withWelcomePage(request): return {'welcomepage':'off'} else: return {}
def getWelcomePage(request): log.info('Call view get_welcome_page.') try: dbsession = request.db # get occurrence of georeferenced messtischblaetter occurrenceGeorefMtbs = int(getCountOfGeorefMesstischblaetter(dbsession)) possibleMtbs = int(getCountOfPublishedMesstischblaetter(dbsession)) georefRelation = int((float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100) # get paginator for user ranking list paginator = Users.get_paginator(request, dbsession) return {'paginator':paginator,'occurrence_mtbs':occurrenceGeorefMtbs, 'possible_mtbs': possibleMtbs, 'georef_rel': georefRelation} except Exception: log.debug('Error while creating paginator for user georeference ranking') log.debug(Exception) return {}
def get_index_page(request): log.info('Call view get_index_page.') # checks if welcome page is activate withWelcomePage = '' if 'welcomepage' in request.params: withWelcomePage = request.params['welcomepage'] # checks if already a user cookie is set and if yes gives back the logged in view if checkIsUser(request): target_url = request.route_url('home_login') return HTTPFound(location = target_url) elif getCookie(request, 'welcomepage') == 'off' or withWelcomePage == 'off': return {'welcomepage':'off', 'faq_url': request.route_url('faq')} else: return {'faq_url': request.route_url('faq')}
def getWelcomePage(request): log.info('Call view get_welcome_page.') try: dbsession = request.db # get occurrence of georeferenced messtischblaetter occurrenceGeorefMtbs = Map.getCountIsGeoref(dbsession) possibleMtbs = Map.getCountIsActive(dbsession) georefRelation = int((float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100) # get paginator for user ranking list paginator = Users.get_paginator(request, dbsession) return {'paginator':paginator,'occurrence_mtbs':occurrenceGeorefMtbs, 'possible_mtbs': possibleMtbs, 'georef_rel': georefRelation} except Exception: log.error('Error while creating paginator for user georeference ranking') log.error(Exception) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def logContactRequest(request): try: log.info('Receive a contact message request.') # check if there is a userid from a registered user userid = checkIsUser(request) if not userid: userid = 'anonym' if 'reference' in request.params: reference = request.params['reference'] if 'message' in request.params: message = request.params['message'] if 'email' in request.params: email = request.params['email'] # check if the input parameters are valide log.debug('Validate the query parameters ...') if not email or not reference or not message: raise MissingQueryParameterError('Missing query parameter ...') if len(message) <= 5: raise WrongParameterException('Message is to short. For a correct understanding of your matter please leave us a short explanation.') # log into database log.debug('Save contact message in the database ...') fehlermeldung = Fehlermeldung(email = email, referenz = reference, nutzerid = userid, fehlerbeschreibung = message, timestamp = getTimestampAsPGStr()) request.db.add(fehlermeldung) # sending an email log.debug('Instruct admin about new contact message ...'); reportErrorMessageToAdmin(fehlermeldung, 'Request - Contact form', userid) log.debug('Create response message ...') return json.dumps({'status':'confirmed'}, ensure_ascii=False, encoding='utf-8') except MissingQueryParameterError: log.error('Could not create correct error report because of missing query parameters.') return Response(json.dumps({'error_message':'Missing form parameters','error_name':'MissingParameterException'}), content_type='application/json', status_int=500) except WrongParameterException as e: log.error(e.msg) return Response(json.dumps({'error_message':e.msg,'error_name':'WrongParameterException'}), content_type='application/json', status_int=500) except DBAPIError: log.error('Problems while trying to register report error in database') return Response(GENERAL_ERROR_MESSAGE, content_type='text/plain', status_int=500) except Exception: log.error('Unknown error while trying to process a contact message request ...') return Response(GENERAL_ERROR_MESSAGE, content_type='text/plain', status_int=500)
def resetGeorefParameters(request): try: log.info('Receive a reset georeference parameter requests.') login = checkIsUser(request) dbsession = request.db messtischblatt_id = request.params['mtbid'] georeference_process = Georeferenzierungsprozess.by_messtischblattid( messtischblatt_id, dbsession) referenz = georeference_process.clipparameter fehlerbeschreibung = 'Zuruecksetzen von Georeferenzierungsparameter für GeorefId=%s' % georeference_process.id if login and messtischblatt_id and referenz and fehlerbeschreibung and Users.by_username( login, dbsession): log.debug('Save reset process in table fehlermeldungen ...') newFehlermeldung = Fehlermeldung( objektid=messtischblatt_id, referenz=referenz, nutzerid=login, fehlerbeschreibung=fehlerbeschreibung, timestamp=getTimestampAsPGStr()) dbsession.add(newFehlermeldung) log.debug('Remove georeference process ...') dbsession.delete(georeference_process) log.debug('Remove refmtblayer ...') try: refmtblayer = RefMtbLayer.by_id(MTB_LAYER_ID, messtischblatt_id, dbsession) dbsession.delete(refmtblayer) except: log.debug('No entry for refmtblayer found ...') pass log.debug('Update messtischblatt db ...') messtischblatt = Messtischblatt.by_id(messtischblatt_id, dbsession) messtischblatt.isttransformiert = False return json.dumps({'status': 'confirmed'}, ensure_ascii=False, encoding='utf-8') except DBAPIError: log.error( 'Problems while trying to remove georeference parameter from the database ...' ) return Response(conn_err_msg, content_type='text/plain', status_int=500)
def getTimestampsForId(request): """ Returns a json document which contains a a list of messtischblatt tuples which have the same blattnumber like the given object. """ try: log.info('Receive request for timestamps for a given object number.') dbsession = request.db object_id = request.GET.get('id') object = Messtischblatt.by_id(object_id, dbsession) spatial_relation_objects = Messtischblatt.allForBlattnr(object.blattnr, dbsession) response = [] for rel_object in spatial_relation_objects: if rel_object.isttransformiert: time = MdZeit.by_id(rel_object.id, dbsession).datierung response.append({'id':rel_object.id,'time':time,'extent':Messtischblatt.getExtent(rel_object.id, dbsession)}) return json.dumps({'maps':response}, ensure_ascii=False, encoding='utf-8') except DBAPIError: return Response(conn_err_msg, content_type='text/plain', status_int=500)
def publishGeorefParameters(request): log.info('Request - Publish georeference result.') try: log.debug('Parse parameters ...') objectid = request.params['objectid'] georeferenceid = request.params['georeferenceid'] messtischblatt = Messtischblatt.by_id(objectid, request.db) georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db) log.debug('Udpate parameters') georeferenceprocess.publish = True messtischblatt.updated = False return json.dumps({'message':'The georeference process is now published. The georeference map will soon be updated and than ready for accessing.'}, ensure_ascii=False, encoding='utf-8') except Exception as e: log.error('Error while trying to request georeference history information'); log.error(e) return {}
def deleteGeorefParameters(request): log.info('Request - Delete georeference result.') try: # remove georeference process georeferenceid = request.params['georeferenceid'] georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db) messtischblattid = georeferenceprocess.messtischblattid request.db.delete(georeferenceprocess) # mark the messtischblatt as updated messtischblatt = Messtischblatt.by_id(messtischblattid, request.db) messtischblatt.udpated = True return json.dumps({'message':'The georeference process has been removed.'}, ensure_ascii=False, encoding='utf-8') except Exception as e: log.error('Error while trying to request georeference history information'); log.error(e) return {}
def getMainPage(request): log.info('Call view get_index_page.') # checks if already a user cookie is set and if yes gives back the logged in view userid = checkIsUser(request) if userid: if ('z' in request.params and 'c' in request.params and 'oid' in request.params) or 'georef' in request.params: return HTTPFound(location=request.route_url( 'home_login', _query=appendParameterToQueryDict(request))) return HTTPFound(location=request.route_url( 'home_login', _query=appendParameterToQueryDict(request, 'georef', 'on'))) if not withWelcomePage(request): return {'welcomepage': 'off'} else: return {}
def georeferenceUpdate(request): log.info('Receive request for processing georeference update result') try: userid = checkIsUser(request) request_data = None if request.method == 'POST': request_data = request.json_body mapObj = parseMapObjForId(request_data, 'id', request.db) log.debug('Id is valide: %s'%request_data) log.debug('Check if there exists a registered georeference process for this messtischblatt ...') if Georeferenzierungsprozess.isGeoreferenced(mapObj.id, request.db) == False: response = {'text':'There is no registered georeference process for this messtischblatt. Please move back to the confirm process.'} return response # actual only support this option if target srs is EPSG:4314 log.debug('Saving georeference process in the database ...') if request_data['georeference']: encoded_clip_params = convertUnicodeDictToUtf(request_data['georeference']) georefProcess = registerUpdateGeoreferenceProcessInDb(mapObj, userid, str(encoded_clip_params), request.db) log.debug('Create response ...') # right now the premise is that for the updated gcps are equal to the removed gcps. For every # updated gcps the users get new points achievement_points = len(request_data['georeference']['remove']['gcps'])*5 response = {'text':'Georeference result updated. It will soon be ready for use.','georeferenceid':georefProcess.id, 'points':achievement_points, 'gcps':request_data['georeference']['new'] ,'type':'update'} return response else: log.error('The remove and new parameters are not valide - %s') raise GeoreferenceParameterError('The remove and new parameters are not valide.') except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def georeferenceGetProcess(request): log.info('Receive request GetGeoreferenceProcess') try: request_data = None if request.method == 'POST': request_data = request.json_body if 'georeferenceid' in request_data: georeferenceid = int(request_data['georeferenceid']) log.debug('Parsed parameters - georeferenceid: %s' % georeferenceid) mapObj = Map.by_id( int( Georeferenzierungsprozess.by_id(georeferenceid, request.db).mapid), request.db) response = createResponseForSpecificGeoreferenceProcess( mapObj, request, georeferenceid) elif 'objectid' in request_data: mapObjId = request_data['objectid'] log.debug('Parsed parameters - mapid: %s' % mapObjId) mapObj = Map.by_id(int(mapObjId), request.db) response = createGeneralResponse(mapObj, request) else: log.error( 'Could not find a georeferenceid or and objectid in the post request parameters ...' ) raise GeoreferenceParameterError return response except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except ProcessIsInvalideException as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest( 'This georeference process is blocked for further work!') except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def deleteGeorefParameters(request): log.info("Request - Delete georeference result.") try: # remove georeference process georeferenceid = request.params["georeferenceid"] georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db) messtischblattid = georeferenceprocess.messtischblattid request.db.delete(georeferenceprocess) # mark the messtischblatt as updated messtischblatt = Messtischblatt.by_id(messtischblattid, request.db) messtischblatt.udpated = True return json.dumps( {"message": "The georeference process has been removed."}, ensure_ascii=False, encoding="utf-8" ) except Exception as e: log.error("Error while trying to request georeference history information") log.error(e) return {}
def getTimestampsForId(request): """ Returns a json document which contains a a list of messtischblatt tuples which have the same blattnumber like the given object. """ try: log.info('Receive request for timestamps for a given object number.') dbsession = request.db object_id = request.GET.get('id') metadataObj = Metadata.by_id(object_id, dbsession) spatial_relation_objects = VBlattschnittMtb.allForBlattnr(metadataObj.blattnr, dbsession) #create response response = [] for rel_object in spatial_relation_objects: if rel_object.isttransformiert: response.append({'id':rel_object.mapid,'time':rel_object.time,'extent': Map.getExtent(rel_object.map, dbsession, DATABASE_SRID)}) return {'maps':response} except DBAPIError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def getProcesses(request): try: log.info('Request - Get georeference processes.') if 'mapid' in request.params: log.debug('Get processes for mapid %s ...'%request.params['mapid']) queryData = request.db.query(Georeferenzierungsprozess, Metadata).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .filter(Georeferenzierungsprozess.mapid == request.params['mapid'])\ .order_by(desc(Georeferenzierungsprozess.id)) elif 'userid' in request.params: log.debug('Get processes for userid %s ...'%request.params['userid']) queryData = request.db.query(Georeferenzierungsprozess, Metadata).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .filter(Georeferenzierungsprozess.nutzerid == request.params['userid'])\ .order_by(desc(Georeferenzierungsprozess.id)) elif 'validation' in request.params: log.debug('Get processes for adminvalidation %s ...'%request.params['validation']) queryData = request.db.query(Georeferenzierungsprozess, Metadata).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .filter(Georeferenzierungsprozess.adminvalidation == request.params['validation'])\ .order_by(desc(Georeferenzierungsprozess.id)) else: log.debug('Get all pending processes ...') queryData = request.db.query(Georeferenzierungsprozess, Metadata).join(Metadata, Georeferenzierungsprozess.mapid == Metadata.mapid)\ .filter(or_(Georeferenzierungsprozess.adminvalidation == '', Georeferenzierungsprozess.adminvalidation == None))\ .order_by(desc(Georeferenzierungsprozess.id)) response = [] for record in queryData: georef = record[0] metadata = record[1] # use encoded_georefParams for visualisation as string on the client side encoded_georefParams = str(convertUnicodeDictToUtf(georef.georefparams)).replace('\'','"') response.append({'georef_id':georef.id, 'mapid':georef.mapid, 'georef_params': encoded_georefParams, 'time': str(metadata.timepublish), 'processed': georef.processed, 'adminvalidation': georef.adminvalidation, 'title': metadata.title, 'apsobjectid': georef.messtischblattid, 'georef_time':str(georef.timestamp),'type':georef.type, 'userid': georef.nutzerid, 'georef_isactive':georef.isactive}) return response except Exception as e: log.error(e) log.error(traceback.format_exc()) return HTTPInternalServerError(GENERAL_ERROR_MESSAGE);
def chooseGeoreferenceMap(request): log.info('Call view getPage_chooseGeorefMtb.') if 'blattnr' in request.params: log.debug('Look for unreferenced messtischblaetter') # get response from database collection = [] metadata = Metadata.all_byBlattnr(request.GET.get('blattnr'), request.db) for record in metadata: map = Map.by_id(record.mapid, request.db) if map.istaktiv and not map.isttransformiert and map.hasgeorefparams == 0: item = {'mapid':map.id,'title':record.title} collection.append(item) log.debug('Create paginator for collection - %s'%collection) page_url = PageURL_WebOb(request) return {'paginator': Page(collection, 1, url=page_url, items_per_page=10)} else: log.error('Could not find a blattnr parameter value ...') log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG)
def setProcessToIsValide(request): log.info('Request - Set admin evaluation of georeference process to isvalide ....') try: # remove georeference process if 'georeferenceid' in request.params: georeferenceid = request.params['georeferenceid'] userid = checkIsUser(request) comment = '' if 'comment' not in request.params else request.params['comment'] # check if georeference id exist georeferenceprocess = Georeferenzierungsprozess.by_id(georeferenceid, request.db) if georeferenceprocess: newJob = createNewAdminJob(georeferenceprocess, 'isvalide', userid, comment) request.db.add(newJob) return {'message':'The georeference process has been set to isvalide.'} else: raise Exception('Missing parameter (georeferenceid) ...') except Exception as e: log.error(e) log.error(traceback.format_exc()) return HTTPBadRequest(GENERAL_ERROR_MESSAGE);
def georeferenceValidation(request): log.info('Receive request for processing georeference validation result') try: request_data = None if request.method == 'POST': request_data = request.json_body mapObj = parseMapObjForId(request_data, 'id', request.db) log.debug('Id is valide: %s'%request_data) log.debug('Start creating validation result ...') # actual only support this option if target srs is EPSG:4314 epsg_code = int(str(request_data['georeference']['target']).split(':')[1]) if request_data['georeference']['source'] == 'pixel' and epsg_code == 4314: log.debug('Parse gcps ...') gcps = parseGcps(request_data['georeference']['gcps']) log.debug('Process georeference parameter ...') destPath = georeference(mapObj.originalimage, os.path.join(GEOREFERENCE_MAPFILE_FOLDER,mapObj.apsdateiname+"::"+str(getUniqueId())+".vrt"), GEOREFERENCE_TMP_DIR, gcps, epsg_code, epsg_code, 'polynom', log) log.debug('Create temporary mapfile ...') wms_url = createMapfile(mapObj.apsdateiname, destPath, GEOREFERENCE_MAPFILE_TEMPLATE, GEOREFERENCE_MAPFILE_FOLDER, GEOREFERENCE_MAPFILE_DEFAULT_PARAMS) log.debug('Create response ...') response = {'wms_url':wms_url,'layer_id':mapObj.apsdateiname,'extent':Map.getExtent(mapObj.id, request.db)} return response else: raise GeoreferenceParameterError('Wrong or missing service parameter') except GeoreferenceParameterError as e: log.error(e) log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except Exception as e: log.error(e) log.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)
def getWelcomePage(request): log.info('Call view get_welcome_page.') try: dbsession = request.db # get occurrence of georeferenced messtischblaetter occurrenceGeorefMtbs = Map.getCountIsGeoref(dbsession) possibleMtbs = Map.getCountIsActive(dbsession) georefRelation = int( (float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100) # get paginator for user ranking list paginator = Users.get_paginator(request, dbsession) return { 'paginator': paginator, 'occurrence_mtbs': occurrenceGeorefMtbs, 'possible_mtbs': possibleMtbs, 'georef_rel': georefRelation } except Exception: log.error( 'Error while creating paginator for user georeference ranking') log.error(Exception) log.error(traceback.format_exc()) raise HTTPInternalServerError(GENERAL_ERROR_MESSAGE)
def getWelcomePage(request): log.info('Call view get_welcome_page.') try: dbsession = request.db # get occurrence of georeferenced messtischblaetter occurrenceGeorefMtbs = int( getCountOfGeorefMesstischblaetter(dbsession)) possibleMtbs = int(getCountOfPublishedMesstischblaetter(dbsession)) georefRelation = int( (float(occurrenceGeorefMtbs) / float(possibleMtbs)) * 100) # get paginator for user ranking list paginator = Users.get_paginator(request, dbsession) return { 'paginator': paginator, 'occurrence_mtbs': occurrenceGeorefMtbs, 'possible_mtbs': possibleMtbs, 'georef_rel': georefRelation } except Exception: log.debug( 'Error while creating paginator for user georeference ranking') log.debug(Exception) return {}
def getPage_profileMtb(request): try: messtischblatt_id = None if 'objectid' in request.params: messtischblatt_id = request.params['objectid'] log.info('Receive get map profile page for id %s.' % messtischblatt_id) georef = False if 'georef' in request.params and request.params['georef'].lower( ) == 'true': georef = True if georef: permalink = createPermalink(request, messtischblatt_id) return HTTPFound(location=permalink) messtischblatt = Messtischblatt.by_id(messtischblatt_id, request.db) metadata = MdCore.by_id(messtischblatt.id, request.db) metadata_datensatz = MdDatensatz.by_ObjectId(messtischblatt.id, request.db) return { 'zoomify_prop': messtischblatt.zoomify_properties, 'zoomify_width': messtischblatt.zoomify_width, 'zoomify_height': messtischblatt.zoomify_height, 'key': 'vk20-md-%s' % messtischblatt.id, 'titel_long': metadata.titel, 'titel_short': metadata.titel_short, 'permalink': metadata_datensatz.permalink } except: log.error( 'Internal server error while trying to get profile page. Please try again or contact the page administrator.' ) raise InternalAuthentificationError( 'Internal server error while trying to get profile page. Please try again or contact the page administrator.' )
def set_visitor_cookie(request): log.info('Call view set_visitor_cookie with params: %s.' % request.params) # parse query parameter setCookie = '' if 'welcomepage' in request.GET: setCookie = request.GET['welcomepage'] # create response if setCookie == 'off': log.debug('Set deactivate welcome page cookie.') response = Response() response.set_cookie('welcomepage', setCookie, max_age=31536000) # max_age = year return response elif setCookie == 'on' and getCookie(request, 'welcomepage') == 'off': log.debug('Set activate welcome page cookie.') response = Response() response.set_cookie('welcomepage', setCookie, max_age=31536000) return response else: log.debug('Value of query parameter \'welcomepage\' is not supported') response = Response() return HTTPBadRequest(headers=response.headers)
def chooseGeoreferenceMap(request): log.info('Call view getPage_chooseGeorefMtb.') if 'blattnr' in request.params: log.debug('Look for unreferenced messtischblaetter') # get response from database collection = [] metadata = Metadata.all_byBlattnr(request.GET.get('blattnr'), request.db) for record in metadata: map = Map.by_id(record.mapid, request.db) if map.istaktiv and not map.isttransformiert and map.hasgeorefparams == 0: item = {'mapid': map.id, 'title': record.title} collection.append(item) log.debug('Create paginator for collection - %s' % collection) page_url = PageURL_WebOb(request) return { 'paginator': Page(collection, 1, url=page_url, items_per_page=10) } else: log.error('Could not find a blattnr parameter value ...') log.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG)
def getGeoreferencePage(request): log.info('Call view getGeoreferencePage.') if 'id' in request.params: return {'objectid': request.params['id']}