# HG changeset patch # User dwinter # Date 1353323665 -3600 # Node ID 1eb5e3f6444b51b9b31c8c7e8ffe466bf5689b09 # Parent 64d6ac1a13547f8444865c9c4645115c1310715b encoding problems with the redirector solved diff -r 64d6ac1a1354 -r 1eb5e3f6444b restService/redirector.py --- a/restService/redirector.py Fri Nov 16 15:26:05 2012 +0100 +++ b/restService/redirector.py Mon Nov 19 12:14:25 2012 +0100 @@ -9,6 +9,7 @@ import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs import logging import urllib +import urllib2 class redirector: @@ -16,8 +17,8 @@ purlHandler=None def __init__(self): #read config file for the viewers - #confFile= file("/usr/local/metadataServices/purlService/restService/viewer.config") - confFile= file("/Users/dwinter/Documents/Projekte/MetaDataManagement/purlService/restService/viewer.config") + confFile= file("/usr/local/metadataServices/purlService/restService/viewer.config") + #confFile= file("/Users/dwinter/Documents/Projekte/MetaDataManagement/purlService/restService/viewer.config") self.purlHandler = manageIndexMetaPURLs.IndexMetaPURLManager() for line in confFile.readlines(): @@ -44,7 +45,14 @@ params = web.input() - + + for key in params.keys(): + if key=="query" and params[key]=="()": #leere frage wegwerfen + del params[key] + + + + splitted=path.split("/") if len(splitted)!=2: #pfrad sollte zwei anteile habe "flavour/purl" raise web.notfound("not found") @@ -91,12 +99,15 @@ - + if len(params.keys())>0: - viewerUrl = viewerFormatString%path+'&'+urllib.urlencode(params) + ret=[key+"="+params[key] for key in params.keys()] + viewerUrl = viewerFormatString%path+'&'+u'&'.join(ret) + + else: viewerUrl = viewerFormatString%path - print viewerUrl + raise web.redirect(viewerUrl,"302 found") if __name__ == '__main__': diff -r 64d6ac1a1354 -r 1eb5e3f6444b restService/restService.py --- a/restService/restService.py Fri Nov 16 15:26:05 2012 +0100 +++ b/restService/restService.py Mon Nov 19 12:14:25 2012 +0100 @@ -30,7 +30,7 @@ class serviceDescription: def __init__(self): - self.render = web.template.render('templates/') + self.render = web.template.render('/usr/local/metadataServices/purlService/restService/templates/') def GET(self): return self.render.serviceDescription() diff -r 64d6ac1a1354 -r 1eb5e3f6444b restService/viewer.config --- a/restService/viewer.config Fri Nov 16 15:26:05 2012 +0100 +++ b/restService/viewer.config Mon Nov 19 12:14:25 2012 +0100 @@ -1,3 +1,3 @@ -echo,http://echo.mpiwg-berlin.mpg.de/ECHOdocuViewfull?url=%s,http://echo.mpiwg-berlin.mpg.de/ECHOdocuViewfull?mode=imagepath&url=%s&viewMode=images -libcoll,http://libcoll.mpiwg-berlin.mpg.de/libviewa?url=%s,http://libcoll.mpiwg-berlin.mpg.de/libviewa?url=%s&viewMode=images +echo,http://echo.mpiwg-berlin.mpg.de/ECHOdocuViewfull?url=%s,http://echo.mpiwg-berlin.mpg.de/ECHOdocuViewfull?mode=imagepath&url=%s +libcoll,http://libcoll.mpiwg-berlin.mpg.de/libviewa?url=%s,http://libcoll.mpiwg-berlin.mpg.de/libviewa?url=%s&mode=imagepath digilib,,http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=%s diff -r 64d6ac1a1354 -r 1eb5e3f6444b searchService/searchLines.py --- a/searchService/searchLines.py Fri Nov 16 15:26:05 2012 +0100 +++ b/searchService/searchLines.py Mon Nov 19 12:14:25 2012 +0100 @@ -9,14 +9,17 @@ import urllib import os.path import json +import urllib2 +import logging -SOLR_SERVER="http://localhost:8983/solr" -DRI_SERVER="http://localhost:8080/purl/" +SOLR_SERVER="https://md.mpiwg-berlin.mpg.de/solr" +DRI_SERVER="http://md.mpiwg-berlin.mpg.de/" class searchLines: def __init__(self): - self.con = solr.SolrConnection(SOLR_SERVER) + #logging.basicConfig(filename='/tmp/solr.log',level=logging.DEBUG) + self.con = solr.SolrConnection(SOLR_SERVER,debug=False) self.search = solr.SearchHandler(self.con,"/fulltexts-line/select") self.searchText = solr.SearchHandler(self.con,"/fulltexts/select") @@ -25,15 +28,21 @@ paras = web.input() if len(paras.keys())==0: - raise web.badrequest("Needs at minimum one of the parametrs: query,doc,dri,page") + raise web.badrequest("Needs at minimum one of the parameters: query,doc,dri,page") queryString=paras.get("query") + + queryString=urllib2.unquote(queryString) + + if not queryString: queryString="q=" + docPath = paras.get("uri") if docPath: + docPath=urllib2.unquote(docPath) #make sure that docpath="/mpiwg/online/..." if not docPath.startswith("/mpiwg/"): if not docPath.startswith("/mpiwg/online/"): @@ -49,9 +58,10 @@ docPath=docPath[0:-1] docPath=os.path.normpath(docPath) + queryString+=""" AND archive-path-folder:"%s" """%docPath - + dri = paras.get('dri') if dri: @@ -80,7 +90,7 @@ queryString+=' AND archive-path-indexMeta:"%s"'%indexMeta - + page= paras.get("pf") if page: @@ -89,21 +99,17 @@ head,name=os.path.split(page) name,ext = os.path.splitext(name) - splitted=name.split(".") # schneide ausserdem das sufffix ab, falls eins da ist. - - if len(splitted)>1: - name=".".join(splitted[0,-1]) queryString+=" AND pf:%s"%name - - response = self.search(queryString,wt="json") + + response = self.search(queryString) ret="" hitId=0 rows=[] - + pageSize=self.getPageSize(queryString) for hit in response: