view restService/restService.py @ 9:5f5447b3a082

repackaging
author dwinter
date Fri, 02 Nov 2012 15:37:17 +0100
parents 733d43b30a82
children fad73212354b
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',
    '/docuviewer/(.+)','redirector',
    '/search','searcher',
)

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


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