Mercurial > hg > documentViewer
comparison documentViewer.py @ 78:70ab234a18dc
bugs in filepath mode fixes
author | dwinter |
---|---|
date | Fri, 06 Mar 2009 16:36:38 +0100 |
parents | 9673218e155b |
children | df6952ac93e9 |
comparison
equal
deleted
inserted
replaced
77:d41833613619 | 78:70ab234a18dc |
---|---|
187 if val is None: | 187 if val is None: |
188 if params.has_key(param): | 188 if params.has_key(param): |
189 del params[param] | 189 del params[param] |
190 else: | 190 else: |
191 params[param] = str(val) | 191 params[param] = str(val) |
192 if params["mode"] == "filepath": #wenn beim erst Aufruf filepath gesetzt wurde aendere das nun zu imagepath | |
193 params["mode"] = "imagepath" | |
194 params["url"] = getParentDir(params["url"]) | |
192 | 195 |
193 # quote values and assemble into query string | 196 # quote values and assemble into query string |
194 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) | 197 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
195 url=self.REQUEST['URL1']+"?"+ps | 198 url=self.REQUEST['URL1']+"?"+ps |
196 return url | 199 return url |
255 num_retries = 3 | 258 num_retries = 3 |
256 if docinfo is None: | 259 if docinfo is None: |
257 docinfo = {} | 260 docinfo = {} |
258 | 261 |
259 for x in range(cut): | 262 for x in range(cut): |
263 | |
260 path=getParentDir(path) | 264 path=getParentDir(path) |
265 | |
261 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path | 266 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
262 | 267 |
263 logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) | 268 logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) |
264 | 269 |
265 for cnt in range(num_retries): | 270 for cnt in range(num_retries): |
352 | 357 |
353 if docinfo is None: | 358 if docinfo is None: |
354 docinfo = {} | 359 docinfo = {} |
355 | 360 |
356 if dom is None: | 361 if dom is None: |
357 for x in range(cut+1): | 362 for x in range(cut): |
358 path=getParentDir(path) | 363 path=getParentDir(path) |
359 dom = self.getIndexMeta(path) | 364 dom = self.getIndexMeta(path) |
360 | 365 |
361 acctype = dom.xpath("//access-conditions/access/@type") | 366 acctype = dom.xpath("//access-conditions/access/@type") |
362 if acctype and (len(acctype)>0): | 367 if acctype and (len(acctype)>0): |
372 """gets bibliographical info from the index.meta file at path or given by dom""" | 377 """gets bibliographical info from the index.meta file at path or given by dom""" |
373 logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) | 378 logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) |
374 | 379 |
375 if docinfo is None: | 380 if docinfo is None: |
376 docinfo = {} | 381 docinfo = {} |
377 | 382 |
378 if dom is None: | 383 if dom is None: |
379 for x in range(cut+1): | 384 for x in range(cut): |
380 path=getParentDir(path) | 385 path=getParentDir(path) |
381 dom = self.getIndexMeta(path) | 386 dom = self.getIndexMeta(path) |
382 | 387 |
383 # put in all raw bib fields as dict "bib" | 388 # put in all raw bib fields as dict "bib" |
384 bib = dom.xpath("//bib/*") | 389 bib = dom.xpath("//bib/*") |
473 #print "image: ", imageDir, " archivepath: ", archivePath | 478 #print "image: ", imageDir, " archivepath: ", archivePath |
474 imageDir=os.path.join(archivePath,imageDir) | 479 imageDir=os.path.join(archivePath,imageDir) |
475 imageDir=imageDir.replace("/mpiwg/online",'') | 480 imageDir=imageDir.replace("/mpiwg/online",'') |
476 docinfo=self.getDirinfoFromDigilib(imageDir,docinfo=docinfo) | 481 docinfo=self.getDirinfoFromDigilib(imageDir,docinfo=docinfo) |
477 docinfo['imagePath'] = imageDir | 482 docinfo['imagePath'] = imageDir |
483 | |
478 docinfo['imageURL'] = self.digilibBaseUrl+"/servlet/Scaler?fn="+imageDir | 484 docinfo['imageURL'] = self.digilibBaseUrl+"/servlet/Scaler?fn="+imageDir |
479 | 485 |
480 viewerUrls=dom.xpath("//texttool/digiliburlprefix") | 486 viewerUrls=dom.xpath("//texttool/digiliburlprefix") |
481 if viewerUrls and (len(viewerUrls)>0): | 487 if viewerUrls and (len(viewerUrls)>0): |
482 viewerUrl=getTextFromNode(viewerUrls[0]) | 488 viewerUrl=getTextFromNode(viewerUrls[0]) |
530 if docinfo is None: | 536 if docinfo is None: |
531 docinfo = {} | 537 docinfo = {} |
532 path=path.replace("/mpiwg/online","") | 538 path=path.replace("/mpiwg/online","") |
533 docinfo['imagePath'] = path | 539 docinfo['imagePath'] = path |
534 docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) | 540 docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) |
541 | |
542 for x in range(cut): | |
543 path=getParentDir(path) | |
544 logging.error("PATH:"+path) | |
535 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path | 545 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
536 docinfo['imageURL'] = imageUrl | 546 docinfo['imageURL'] = imageUrl |
537 | 547 |
538 docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) | 548 docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
539 docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) | 549 docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
586 np = int(docinfo['numPages']) | 596 np = int(docinfo['numPages']) |
587 pageinfo['end'] = min(pageinfo['end'], np) | 597 pageinfo['end'] = min(pageinfo['end'], np) |
588 pageinfo['numgroups'] = int(np / grpsize) | 598 pageinfo['numgroups'] = int(np / grpsize) |
589 if np % grpsize > 0: | 599 if np % grpsize > 0: |
590 pageinfo['numgroups'] += 1 | 600 pageinfo['numgroups'] += 1 |
591 logging.debug("getPageInfo: %s"%repr(pageinfo)) | 601 |
592 return pageinfo | 602 return pageinfo |
593 | 603 |
594 def text(self,mode,url,pn): | 604 def text(self,mode,url,pn): |
595 """give text""" | 605 """give text""" |
596 if mode=="texttool": #index.meta with texttool information | 606 if mode=="texttool": #index.meta with texttool information |