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