# HG changeset patch # User dwinter # Date 1363167452 -3600 # Node ID 6776aeff118ccb2aebb8a7a3f110b7033196fa8b # Parent 9ef155b1eec5a01c6c7a2611e0af5982da1e12e8 added imageURL to the services diff -r 9ef155b1eec5 -r 6776aeff118c restService/restService.py --- a/restService/restService.py Tue Mar 12 14:41:40 2013 +0100 +++ b/restService/restService.py Wed Mar 13 10:37:32 2013 +0100 @@ -27,14 +27,15 @@ '/searchLines/annotator/search','searchLines', '/getPurls','getPurls', '/searchSolr','searchSolr', - '/imagePath/(.+)','imagePath' + '/imagePath/(.+)','imagePath', + '/imageURL/(.+)','imageURL' ) app = web.application(urls, globals()) - +SCALERPATH="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=%s" @@ -80,7 +81,7 @@ path,validity=self.md.getPathValidity(purl) if path is None: - raise web.notfound("Cannnot find a URL to this path") + raise web.notfound("Cannnot find a URL to this purl") if validity is manageIndexMetaPURLs.PERM_NON_VALID: raise web.notfound("PURL NON VALID ANYMORE!") @@ -102,7 +103,7 @@ path,validity=self.md.getImagePathValidity(purl) if path is None: - raise web.notfound("Cannnot find a URL to this path") + raise web.notfound("Cannnot find a URL to this purl") if validity is manageIndexMetaPURLs.PERM_NON_VALID: raise web.notfound("PURL NON VALID ANYMORE!") @@ -114,7 +115,46 @@ return path +class imageURL: + def __init__(self): + self.md=manageIndexMetaPURLs.IndexMetaPURLManager() + + def GET(self,purl): + + #first try check if path stored + path,validity=self.md.getImagePathValidity(purl) + + if path=="": + print "no path" + #second try gessing + path,validity=self.md.getPathValidity(purl) + + path=path.replace("index.meta","pageimg") #hope that images are stored at the required place + + if path.startswith("http"): # there is a url stored, than this cannot be a path for the image server + raise web.notfound("NO IMAGE PATH STORED FOUND AN URL(%s)!"%path) + + if validity is manageIndexMetaPURLs.PERM_NON_VALID: + raise web.notfound("PURL NON VALID ANYMORE!") + + if validity is manageIndexMetaPURLs.TEMP_NON_VALID: + return web.notfound("PURL currently not VALID try later!") + + + data = web.input() + + if not 'dw' in data.keys(): + data['dw']="100" + + if not 'dh' in data.keys(): + data['dh']="100" + + + return SCALERPATH%path+"&"+"&".join(["%s=%s"%(key,value) for key,value in data.items()]) + + #http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/echo/hellinomnimon/Gazis-Gram_A/img&dw=1298&dh=915&pn=3 + if __name__ == "__main__": app.run()