annotate restService/restService.py @ 9:5f5447b3a082

repackaging
author dwinter
date Fri, 02 Nov 2012 15:37:17 +0100
parents 733d43b30a82
children fad73212354b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
1 '''
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
2 Created on 31.10.2012
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
3
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
4 @author: dwinter
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
5 '''
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
6 import web
9
5f5447b3a082 repackaging
dwinter
parents: 8
diff changeset
7 import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs
3
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
8 from redirector import redirector
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
9 import logging
8
733d43b30a82 connection handling changed
dwinter
parents: 5
diff changeset
10 from searcher import searcher
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
11
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
12 urls = (
3
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
13 '/purl/(.+)','purl',
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
14 '/docuviewer/(.+)','redirector',
8
733d43b30a82 connection handling changed
dwinter
parents: 5
diff changeset
15 '/search','searcher',
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
16 )
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
17
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
18 app = web.application(urls, globals())
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
19
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
20
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
21 class purl:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
22
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
23 def __init__(self):
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
24 self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
25
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
26 def GET(self,purl):
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
27
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
28 path,validity=self.md.getPathValidity(purl)
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
29
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
30 if path is None:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
31 raise web.notfound("Cannnot find a URL to this path")
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
32
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
33 if validity is manageIndexMetaPURLs.PERM_NON_VALID:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
34 raise web.notfound("PURL NON VALID ANYMORE!")
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
35
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
36 if validity is manageIndexMetaPURLs.TEMP_NON_VALID:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
37 return web.notfound("PURL currently not VALID try later!")
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
38
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
39
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
40 return path
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
41
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
42
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
43 if __name__ == "__main__":
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
44 app.run()