annotate restService/restService.py @ 40:671dd1e4bd09 default tip

minor bug
author dwinter
date Wed, 05 Mar 2014 10:20:54 +0100
parents 6d0d7f1c11f2
children
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 '''
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
6
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
7
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
8 import web
9
5f5447b3a082 repackaging
dwinter
parents: 8
diff changeset
9 import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs
14
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
10 from redirector import redirector
3
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
11 import logging
8
733d43b30a82 connection handling changed
dwinter
parents: 5
diff changeset
12 from searcher import searcher
30
bcd8076ff7ec random selection of entries
dwinter
parents: 28
diff changeset
13 from getPurls import randomSearch
bcd8076ff7ec random selection of entries
dwinter
parents: 28
diff changeset
14 from getPurls import lastEntries
bcd8076ff7ec random selection of entries
dwinter
parents: 28
diff changeset
15
16
70110fb915a9 searchlines
dwinter
parents: 14
diff changeset
16 from searchService.searchLines import searchLines
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
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
6d0d7f1c11f2 /dris added to the api
dwinter
parents: 30
diff changeset
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
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
23 import config
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
24
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
25
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
26 urls = (
3
caeede0c9464 update and redirector
dwinter
parents: 2
diff changeset
27 '/purl/(.+)','purl',
12
0287aed01f2b config and minor bugs
dwinter
parents: 11
diff changeset
28 '/docuview/(.+)','redirector',
8
733d43b30a82 connection handling changed
dwinter
parents: 5
diff changeset
29 '/search','searcher',
13
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
30 '/indexMeta/(.+)','indexMeta',
16
70110fb915a9 searchlines
dwinter
parents: 14
diff changeset
31 '/','serviceDescription',
17
64d6ac1a1354 parameter for search changed
dwinter
parents: 16
diff changeset
32 '/searchLines','searchLines',
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
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
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
35 '/searchSolr','searchSolr',
25
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
36 '/imagePath/(.+)','imagePath',
27
cbae1998a2a9 image added
dwinter
parents: 25
diff changeset
37 '/imageURL/(.+)','imageURL',
30
bcd8076ff7ec random selection of entries
dwinter
parents: 28
diff changeset
38 '/image/(.+)','image',
bcd8076ff7ec random selection of entries
dwinter
parents: 28
diff changeset
39 '/random','randomSearch',
38
6d0d7f1c11f2 /dris added to the api
dwinter
parents: 30
diff changeset
40 '/last','lastEntries',
6d0d7f1c11f2 /dris added to the api
dwinter
parents: 30
diff changeset
41 '/dris','dris'
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
42 )
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
43
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
44
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
45 app = web.application(urls, globals())
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
46
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
47
25
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
48 SCALERPATH="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=%s"
13
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
49
14
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
50
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
51
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
52 class serviceDescription:
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
53
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
54 def __init__(self):
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
55 self.render = web.template.render(config.TEMPLATE_PATH)
14
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
56 def GET(self):
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
57
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
58 return self.render.serviceDescription()
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
59
13
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
60 class indexMeta:
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
61
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
62 def __init__(self):
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
63 self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
64
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
65
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
66 def GET(self,purl):
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
67
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
68 path,validity=self.md.getPathValidity(purl)
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
69
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
70 if path is None:
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
71 raise web.notfound("Cannnot find a URL to this path")
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
72
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
73 if validity is manageIndexMetaPURLs.PERM_NON_VALID:
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
74 raise web.notfound("PURL NON VALID ANYMORE!")
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
75
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
76 if validity is manageIndexMetaPURLs.TEMP_NON_VALID:
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
77 return web.notfound("PURL currently not VALID try later!")
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
78
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
79
19
cce127a28fc9 added getpurls
dwinter
parents: 18
diff changeset
80 raise web.redirect(config.TEXTER_URL%path)
14
a2bcca6539fd static pages
dwinter
parents: 13
diff changeset
81
13
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
82
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
83
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
84 class purl:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
85
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
86 def __init__(self):
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
87 self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
88
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
89 def GET(self,purl):
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
90
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
91 path,validity=self.md.getPathValidity(purl)
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
92
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
93 if path is None:
25
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
94 raise web.notfound("Cannnot find a URL to this purl")
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
95
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
96 if validity is manageIndexMetaPURLs.PERM_NON_VALID:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
97 raise web.notfound("PURL NON VALID ANYMORE!")
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
98
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
99 if validity is manageIndexMetaPURLs.TEMP_NON_VALID:
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
100 return web.notfound("PURL currently not VALID try later!")
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
101
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
102
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
103 return path
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
104
13
a1577a498c85 metadata redirector added
dwinter
parents: 12
diff changeset
105
23
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
106 class imagePath:
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
107
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
108 def __init__(self):
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
109 self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
110
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
111 def GET(self,purl):
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
112
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
113 path,validity=self.md.getImagePathValidity(purl)
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
114
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
115 if path is None:
25
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
116 raise web.notfound("Cannnot find a URL to this purl")
23
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
117
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
118 if validity is manageIndexMetaPURLs.PERM_NON_VALID:
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
119 raise web.notfound("PURL NON VALID ANYMORE!")
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
120
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
121 if validity is manageIndexMetaPURLs.TEMP_NON_VALID:
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
122 return web.notfound("PURL currently not VALID try later!")
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
123
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
124
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
125 return path
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
126
7fdd2d68fd6b imagepath added
dwinter
parents: 20
diff changeset
127
25
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
128
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
129 #http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/echo/hellinomnimon/Gazis-Gram_A/img&dw=1298&dh=915&pn=3
6776aeff118c added imageURL to the services
dwinter
parents: 23
diff changeset
130
2
fb2a3b4542a4 restservice
dwinter
parents:
diff changeset
131 if __name__ == "__main__":
11
fad73212354b wsgi addedx
dwinter
parents: 9
diff changeset
132 app.run()