view restService/restService.py @ 14:a2bcca6539fd

static pages
author dwinter
date Mon, 12 Nov 2012 09:29:28 +0100
parents a1577a498c85
children 70110fb915a9
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

urls = (
    '/purl/(.+)','purl',
    '/docuview/(.+)','redirector',
    '/search','searcher',
    '/indexMeta/(.+)','indexMeta',
    '/','serviceDescription'
)

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


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



class serviceDescription:
    
    def __init__(self):
        self.render = web.template.render('templates/')
    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(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 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!")
       
        
        return path
        
    


if __name__ == "__main__":
    app.run()