view restService/restService.py @ 36:be8640c08d99

Updatedri in harbestToPUrl ge?ndert. jetzt werden gegebenenfalls dris aus den index.meta gelesen und in die db geschrieben, falls sie noch nicht existieren. ausserdem wird in den daten isdri=TRUE gesetzt, wenn es ich bei der PURL um eine handelt die auf ein DRI in den index.meta verweist.
author dwinter
date Mon, 03 Mar 2014 17:32:06 +0100
parents bcd8076ff7ec
children 6d0d7f1c11f2
line wrap: on
line source

'''
Created on 31.10.2012

@author: dwinter
'''


import web
import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs
from redirector import redirector 
import logging
from searcher import searcher
from getPurls import randomSearch
from getPurls import lastEntries

from searchService.searchLines import searchLines
from getPurls import getPurls
from searchService.searchSolr import searchSolr
from images import image
from images import imageURL

import config


urls = (
    '/purl/(.+)','purl',
    '/docuview/(.+)','redirector',
    '/search','searcher',
    '/indexMeta/(.+)','indexMeta',
    '/','serviceDescription',
    '/searchLines','searchLines',
    '/searchLines/annotator/search','searchLines',
    '/getPurls','getPurls',
    '/searchSolr','searchSolr',
    '/imagePath/(.+)','imagePath',
    '/imageURL/(.+)','imageURL',
    '/image/(.+)','image',
    '/random','randomSearch',
    '/last','lastEntries'
)


app = web.application(urls, globals())


SCALERPATH="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=%s"



class serviceDescription:
    
    def __init__(self):
        self.render = web.template.render(config.TEMPLATE_PATH)
    def GET(self):
        
        return self.render.serviceDescription()

class indexMeta:
    
    def __init__(self):
        self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
        

    def GET(self,purl):
        
        path,validity=self.md.getPathValidity(purl)
        
        if path is None:
            raise web.notfound("Cannnot find a URL to this 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!")
       
        
        raise web.redirect(config.TEXTER_URL%path)



class purl:
    
    def __init__(self):
        self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
        
    def GET(self,purl):
        
        path,validity=self.md.getPathValidity(purl)
        
        if path is None:
            raise web.notfound("Cannnot find a URL to this purl")
        
        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!")
       
        
        return path
        
    
class imagePath:
    
    def __init__(self):
        self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
        
    def GET(self,purl):
        
        path,validity=self.md.getImagePathValidity(purl)
        
        if path is None:
            raise web.notfound("Cannnot find a URL to this purl")
        
        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!")
       
        
        return path
        
    

 #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()