comparison documentViewer.py @ 29:e1bed068b351

small fixes
author casties
date Mon, 10 Apr 2006 13:23:18 +0200
parents b9a867a67477
children c6451e8d5d23
comparison
equal deleted inserted replaced
28:b9a867a67477 29:e1bed068b351
41 socket.setdefaulttimeout(2) 41 socket.setdefaulttimeout(2)
42 ret=urllib.urlopen(url) 42 ret=urllib.urlopen(url)
43 socket.setdefaulttimeout(5) 43 socket.setdefaulttimeout(5)
44 return ret 44 return ret
45 45
46 def getParamFromDigilib(path,param):
47 """gibt param von dlInfo aus"""
48 imageUrl=genericDigilib+"/dirInfo-xml.jsp?mo=dir&fn="+path
49
50 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo (%s) from %s"%(param,imageUrl))
51
52 try:
53 dom = NonvalidatingReader.parseUri(imageUrl)
54 except:
55 return None
56
57 params=dom.xpath("//dir/%s"%param)
58 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:%s"%params)
59
60 if params:
61 return getTextFromNode(params[0])
62
63 46
64 47
65 48
66 ## 49 ##
67 ## documentViewer class 50 ## documentViewer class
109 @param mode: defines which type of document is behind url 92 @param mode: defines which type of document is behind url
110 @param url: url which contains display information 93 @param url: url which contains display information
111 ''' 94 '''
112 95
113 zLOG.LOG("documentViewer (index)", zLOG.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) 96 zLOG.LOG("documentViewer (index)", zLOG.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
114 print "dlbaseurl:", self.digilibBaseUrl
115 97
116 if not hasattr(self, 'template'): 98 if not hasattr(self, 'template'):
117 # create template folder if it doesn't exist 99 # create template folder if it doesn't exist
118 print "no template folder -- creating" 100 print "no template folder -- creating"
119 self.manage_addFolder('template') 101 self.manage_addFolder('template')
147 return style + 'sel' 129 return style + 'sel'
148 else: 130 else:
149 return style 131 return style
150 132
151 133
134 def getParamFromDigilib(self,path,param):
135 """gibt param von dlInfo aus"""
136 imageUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
137
138 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo (%s) from %s"%(param,imageUrl))
139
140 try:
141 dom = NonvalidatingReader.parseUri(imageUrl)
142 except:
143 return None
144
145 params=dom.xpath("//dir/%s"%param)
146 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:%s"%params)
147
148 if params:
149 return getTextFromNode(params[0])
150
151
152 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): 152 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None):
153 """gets bibliographical info from the index.meta file at url or given by dom""" 153 """gets bibliographical info from the index.meta file at url or given by dom"""
154 zLOG.LOG("documentViewer (getbibinfofromindexmeta)", zLOG.INFO,"path: %s"%(path)) 154 zLOG.LOG("documentViewer (getbibinfofromindexmeta)", zLOG.INFO,"path: %s"%(path))
155 155
156 if docinfo is None: 156 if docinfo is None:
208 image=None 208 image=None
209 209
210 if image and archivePath: 210 if image and archivePath:
211 image=os.path.join(archivePath,image) 211 image=os.path.join(archivePath,image)
212 image=image.replace("/mpiwg/online",'') 212 image=image.replace("/mpiwg/online",'')
213 pt=getParamFromDigilib(image,'size') 213 pt=self.getParamFromDigilib(image,'size')
214 docinfo['imagePath'] = image 214 docinfo['imagePath'] = image
215 docinfo['numPages'] = pt 215 docinfo['numPages'] = pt
216 216
217 viewerUrls=dom.xpath("//texttool/digiliburlprefix") 217 viewerUrls=dom.xpath("//texttool/digiliburlprefix")
218 218
233 def getDocinfoFromImagePath(self,path,docinfo=None): 233 def getDocinfoFromImagePath(self,path,docinfo=None):
234 """path ist the path to the images it assumes that the index.meta file is one level higher.""" 234 """path ist the path to the images it assumes that the index.meta file is one level higher."""
235 zLOG.LOG("documentViewer (getdocinfofromimagepath)", zLOG.INFO,"path: %s"%(path)) 235 zLOG.LOG("documentViewer (getdocinfofromimagepath)", zLOG.INFO,"path: %s"%(path))
236 if docinfo is None: 236 if docinfo is None:
237 docinfo = {} 237 docinfo = {}
238 path=path.replace("/mpiwg/online","")
238 docinfo['imagePath'] = path 239 docinfo['imagePath'] = path
239 path=path.replace("/mpiwg/online","") 240 pt=self.getParamFromDigilib(path,'size')
240 pt=getParamFromDigilib(path,'size')
241 docinfo['numPages'] = pt 241 docinfo['numPages'] = pt
242 imageUrl=genericDigilib+"/servlet/Scaler?fn=%s"%path 242 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn=%s"%path
243 docinfo['imageURL'] = imageUrl 243 docinfo['imageURL'] = imageUrl
244 244
245 docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo) 245 docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo)
246 return docinfo 246 return docinfo
247 247