def index(): # get PID to examine, if noted # if request.args.get("PIDnum") != None: if "PIDnum" in request.values: PIDnum = int(request.args.get("PIDnum")) else: PIDnum = 0 # gen PIDlet PIDlet = jobs.genPIDlet(PIDnum) if PIDlet == False: return utilities.applicationError("PIDnum is out of range.") PIDlet['pURL'] = "/tasks/editDSRegex?PIDnum="+str(PIDnum-1) PIDlet['nURL'] = "/tasks/editDSRegex?PIDnum="+str(PIDnum+1) # instantiate forms form = RDF_edit() # Raw Datastream via Fedora API ############################################################### raw_xml_URL = "http://{APP_HOST}/fedora/objects/{PID}/datastreams/MODS/content".format(PID=PIDlet['cPID'],APP_HOST=localConfig.APP_HOST) raw_xml = requests.get(raw_xml_URL).text.encode("utf-8") ############################################################### # return render_template("editDSRegex_index.html",PID=PIDs[PIDnum],PIDnum=PIDnum,len_PIDs=len(PIDs),form=form,raw_xml=raw_xml) return render_template("editDSRegex_index.html",PIDlet=PIDlet,PIDnum=PIDnum,form=form,raw_xml=raw_xml)
def index(PIDnum): # gen PIDlet PIDlet = jobs.genPIDlet(int(PIDnum)) if PIDlet == False: return utilities.applicationError("PIDnum is out of range.") PIDlet['pURL'] = "/tasks/editDSMime/"+str(int(PIDnum)-1) PIDlet['nURL'] = "/tasks/editDSMime/"+str(int(PIDnum)+1) PID = PIDlet['cPID'] # get datastreams for object obj_ohandle = fedora_handle.get_object(PID) ds_list = obj_ohandle.ds_list return render_template("editDSMime.html", PIDlet=PIDlet, PIDnum=PIDnum, ds_list=ds_list, APP_HOST=localConfig.APP_HOST)
def editRELS_advanced(): ''' /tasks/editRELS/blanket?PIDnum={{(PIDnum - 1)}} ''' # get PID to examine, if noted if request.args.get("PIDnum") != None: PIDnum = int(request.args.get("PIDnum")) else: PIDnum = 0 # gen PIDlet PIDlet = jobs.genPIDlet(int(PIDnum)) if PIDlet == False: return utilities.applicationError("PIDnum is out of range.") PIDlet['pURL'] = "/tasks/editRELS/advanced?PIDnum="+str(int(PIDnum)-1) PIDlet['nURL'] = "/tasks/editRELS/advanced?PIDnum="+str(int(PIDnum)+1) # instantiate forms form = RDF_edit() # get triples for 1st object riquery = fedora_handle.risearch.spo_search(subject="info:fedora/"+PIDlet['cPID'], predicate=None, object=None) # filter out RELS-EXT and WSUDOR predicates riquery_filtered = [] for s,p,o in riquery: try: if "relations-external" in p or "WSUDOR-Fedora-Relations" in p: riquery_filtered.append((p,o)) except: print "Could not parse RDF relationship" riquery_filtered.sort() #mild sorting applied to group WSUDOR or RELS-EXT # Raw Datastream via Fedora API ############################################################### raw_xml_URL = "http://localhost/fedora/objects/%s/datastreams/RELS-EXT/content" % (PIDlet['cPID']) raw_xml = requests.get(raw_xml_URL).text.encode("utf-8") ############################################################### # return render_template("editRELS_advanced.html",riquery_filtered=riquery_filtered,PID=PIDs[PIDnum],PIDnum=PIDnum,len_PIDs=len(PIDs),form=form,raw_xml=raw_xml) return render_template("editRELS_advanced.html",riquery_filtered=riquery_filtered,PIDlet=PIDlet,form=form,raw_xml=raw_xml)
def viewManifests(PIDnum): # get PIDs PIDs = getSelPIDs() # GET CURRENT OBJECTS PIDlet = genPIDlet(int(PIDnum)) if PIDlet == False: return utilities.applicationError("PIDnum is out of range or invalid. We are is displeased.") PIDlet['pURL'] = "/tasks/iiifManifest/viewManifests/"+str(int(PIDnum)-1) PIDlet['nURL'] = "/tasks/iiifManifest/viewManifests/"+str(int(PIDnum)+1) # check Redis for manifest r_response = redisHandles.r_iiif.get(PIDlet['cPID']) if r_response != None: print "Redis hit for manifest." json_return = r_response else: print "Redis miss for manifest." json_return = json.dumps({"status":"manifest for %s not found in redis" % PIDlet['cPID']}) return render_template("iiifManifest_view.html",PIDnum=(int(PIDnum)+1),PIDlet=PIDlet, json_return=json.dumps( json.loads(json_return), indent=2), iiif_manifest_prefix=localConfig.IIIF_MANIFEST_PREFIX,APP_HOST=localConfig.APP_HOST )