Mercurial > hg > purlService
annotate restService/restService.py @ 40:671dd1e4bd09 default tip
minor bug
author | dwinter |
---|---|
date | Wed, 05 Mar 2014 10:20:54 +0100 |
parents | 6d0d7f1c11f2 |
children |
rev | line source |
---|---|
2 | 1 ''' |
2 Created on 31.10.2012 | |
3 | |
4 @author: dwinter | |
5 ''' | |
19 | 6 |
7 | |
2 | 8 import web |
9 | 9 import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs |
14 | 10 from redirector import redirector |
3 | 11 import logging |
8 | 12 from searcher import searcher |
30 | 13 from getPurls import randomSearch |
14 from getPurls import lastEntries | |
15 | |
16 | 16 from searchService.searchLines import searchLines |
19 | 17 from getPurls import getPurls |
20
cf4503528b5e
searchsolr neue function, zun?chst nur f?r text-url-path
dwinter
parents:
19
diff
changeset
|
18 from searchService.searchSolr import searchSolr |
28
246049db5466
getImagePath askes now the md server for the image path
dwinter
parents:
27
diff
changeset
|
19 from images import image |
246049db5466
getImagePath askes now the md server for the image path
dwinter
parents:
27
diff
changeset
|
20 from images import imageURL |
38 | 21 from getPurls import dris |
20
cf4503528b5e
searchsolr neue function, zun?chst nur f?r text-url-path
dwinter
parents:
19
diff
changeset
|
22 |
19 | 23 import config |
24 | |
2 | 25 |
26 urls = ( | |
3 | 27 '/purl/(.+)','purl', |
12 | 28 '/docuview/(.+)','redirector', |
8 | 29 '/search','searcher', |
13 | 30 '/indexMeta/(.+)','indexMeta', |
16 | 31 '/','serviceDescription', |
17 | 32 '/searchLines','searchLines', |
19 | 33 '/searchLines/annotator/search','searchLines', |
20
cf4503528b5e
searchsolr neue function, zun?chst nur f?r text-url-path
dwinter
parents:
19
diff
changeset
|
34 '/getPurls','getPurls', |
23 | 35 '/searchSolr','searchSolr', |
25 | 36 '/imagePath/(.+)','imagePath', |
27 | 37 '/imageURL/(.+)','imageURL', |
30 | 38 '/image/(.+)','image', |
39 '/random','randomSearch', | |
38 | 40 '/last','lastEntries', |
41 '/dris','dris' | |
2 | 42 ) |
43 | |
19 | 44 |
2 | 45 app = web.application(urls, globals()) |
46 | |
47 | |
25 | 48 SCALERPATH="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=%s" |
13 | 49 |
14 | 50 |
51 | |
52 class serviceDescription: | |
53 | |
54 def __init__(self): | |
19 | 55 self.render = web.template.render(config.TEMPLATE_PATH) |
14 | 56 def GET(self): |
57 | |
58 return self.render.serviceDescription() | |
59 | |
13 | 60 class indexMeta: |
61 | |
62 def __init__(self): | |
63 self.md=manageIndexMetaPURLs.IndexMetaPURLManager() | |
64 | |
65 | |
66 def GET(self,purl): | |
67 | |
68 path,validity=self.md.getPathValidity(purl) | |
69 | |
70 if path is None: | |
71 raise web.notfound("Cannnot find a URL to this path") | |
72 | |
73 if validity is manageIndexMetaPURLs.PERM_NON_VALID: | |
74 raise web.notfound("PURL NON VALID ANYMORE!") | |
75 | |
76 if validity is manageIndexMetaPURLs.TEMP_NON_VALID: | |
77 return web.notfound("PURL currently not VALID try later!") | |
78 | |
79 | |
19 | 80 raise web.redirect(config.TEXTER_URL%path) |
14 | 81 |
13 | 82 |
83 | |
2 | 84 class purl: |
85 | |
86 def __init__(self): | |
87 self.md=manageIndexMetaPURLs.IndexMetaPURLManager() | |
88 | |
89 def GET(self,purl): | |
90 | |
91 path,validity=self.md.getPathValidity(purl) | |
92 | |
93 if path is None: | |
25 | 94 raise web.notfound("Cannnot find a URL to this purl") |
2 | 95 |
96 if validity is manageIndexMetaPURLs.PERM_NON_VALID: | |
97 raise web.notfound("PURL NON VALID ANYMORE!") | |
98 | |
99 if validity is manageIndexMetaPURLs.TEMP_NON_VALID: | |
100 return web.notfound("PURL currently not VALID try later!") | |
101 | |
102 | |
103 return path | |
104 | |
13 | 105 |
23 | 106 class imagePath: |
107 | |
108 def __init__(self): | |
109 self.md=manageIndexMetaPURLs.IndexMetaPURLManager() | |
110 | |
111 def GET(self,purl): | |
112 | |
113 path,validity=self.md.getImagePathValidity(purl) | |
114 | |
115 if path is None: | |
25 | 116 raise web.notfound("Cannnot find a URL to this purl") |
23 | 117 |
118 if validity is manageIndexMetaPURLs.PERM_NON_VALID: | |
119 raise web.notfound("PURL NON VALID ANYMORE!") | |
120 | |
121 if validity is manageIndexMetaPURLs.TEMP_NON_VALID: | |
122 return web.notfound("PURL currently not VALID try later!") | |
123 | |
124 | |
125 return path | |
126 | |
127 | |
25 | 128 |
129 #http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/echo/hellinomnimon/Gazis-Gram_A/img&dw=1298&dh=915&pn=3 | |
130 | |
2 | 131 if __name__ == "__main__": |
11 | 132 app.run() |