changeset 27:cbae1998a2a9

image added
author dwinter
date Wed, 13 Mar 2013 11:02:20 +0100
parents f9391feb92ca
children 246049db5466
files restService/restService.py
diffstat 1 files changed, 41 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/restService/restService.py	Wed Mar 13 10:39:21 2013 +0100
+++ b/restService/restService.py	Wed Mar 13 11:02:20 2013 +0100
@@ -28,7 +28,8 @@
     '/getPurls','getPurls',
     '/searchSolr','searchSolr',
     '/imagePath/(.+)','imagePath',
-    '/imageURL/(.+)','imageURL'
+    '/imageURL/(.+)','imageURL',
+    '/image/(.+)','image'
 )
 
 
@@ -153,6 +154,45 @@
           
         
         return SCALERPATH%path+"&"+"&".join(["%s=%s"%(key,value) for key,value in data.items()])
+
+class image:
+    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"
+          
+        
+        raise web.redirect(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