version 1.32, 2008/06/25 10:47:58
|
version 1.37, 2008/11/04 22:03:56
|
Line 21 import logging
|
Line 21 import logging
|
import math |
import math |
|
|
import urlparse |
import urlparse |
|
from types import * |
def logger(txt,method,txt2): |
def logger(txt,method,txt2): |
"""logging""" |
"""logging""" |
logging.info(txt+ txt2) |
logging.info(txt+ txt2) |
Line 139 class documentViewer(Folder):
|
Line 139 class documentViewer(Folder):
|
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) |
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) |
|
|
security.declareProtected('View','index_html') |
security.declareProtected('View','index_html') |
def index_html(self,mode,url,viewMode="auto",start=None,pn=1): |
def index_html(self,mode,url,viewMode="auto",start=None,pn=1,mk=None): |
''' |
''' |
view it |
view it |
@param mode: defines how to access the document behind url |
@param mode: defines how to access the document behind url |
Line 167 class documentViewer(Folder):
|
Line 167 class documentViewer(Folder):
|
else: |
else: |
viewMode="images" |
viewMode="images" |
|
|
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) |
return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk)) |
|
|
|
def generateMarks(self,mk): |
|
ret="" |
|
if mk is None: |
|
return "" |
|
|
|
if type(mk) is not ListType: |
|
mk=[mk] |
|
for m in mk: |
|
ret+="mk=%s"%m |
|
return ret |
|
|
def getLink(self,param=None,val=None): |
def getLink(self,param=None,val=None): |
"""link to documentviewer with parameter param set to val""" |
"""link to documentviewer with parameter param set to val""" |
Line 240 class documentViewer(Folder):
|
Line 250 class documentViewer(Folder):
|
return False |
return False |
|
|
|
|
def getDirinfoFromDigilib(self,path,docinfo=None): |
def getDirinfoFromDigilib(self,path,docinfo=None,cut=0): |
"""gibt param von dlInfo aus""" |
"""gibt param von dlInfo aus""" |
num_retries = 3 |
num_retries = 3 |
if docinfo is None: |
if docinfo is None: |
docinfo = {} |
docinfo = {} |
|
|
|
for x in range(cut): |
|
path=getParentDir(path) |
infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
|
|
logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) |
logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl)) |
Line 286 class documentViewer(Folder):
|
Line 298 class documentViewer(Folder):
|
metaUrl=server+url.replace("/mpiwg/online","") |
metaUrl=server+url.replace("/mpiwg/online","") |
if not metaUrl.endswith("index.meta"): |
if not metaUrl.endswith("index.meta"): |
metaUrl += "/index.meta" |
metaUrl += "/index.meta" |
print metaUrl |
logging.debug("METAURL: %s"%metaUrl) |
for cnt in range(num_retries): |
for cnt in range(num_retries): |
try: |
try: |
# patch dirk encoding fehler treten dann nicht mehr auf |
# patch dirk encoding fehler treten dann nicht mehr auf |
Line 332 class documentViewer(Folder):
|
Line 344 class documentViewer(Folder):
|
return dom |
return dom |
|
|
|
|
def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None): |
def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
"""gets authorization info from the index.meta file at path or given by dom""" |
"""gets authorization info from the index.meta file at path or given by dom""" |
logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path)) |
logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path)) |
|
|
Line 342 class documentViewer(Folder):
|
Line 354 class documentViewer(Folder):
|
docinfo = {} |
docinfo = {} |
|
|
if dom is None: |
if dom is None: |
dom = self.getIndexMeta(getParentDir(path)) |
for x in range(cut+1): |
|
path=getParentDir(path) |
|
dom = self.getIndexMeta(path) |
|
|
acctype = dom.xpath("//access-conditions/access/@type") |
acctype = dom.xpath("//access-conditions/access/@type") |
if acctype and (len(acctype)>0): |
if acctype and (len(acctype)>0): |
Line 354 class documentViewer(Folder):
|
Line 368 class documentViewer(Folder):
|
return docinfo |
return docinfo |
|
|
|
|
def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): |
def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
"""gets bibliographical info from the index.meta file at path or given by dom""" |
"""gets bibliographical info from the index.meta file at path or given by dom""" |
logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) |
logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) |
|
|
Line 362 class documentViewer(Folder):
|
Line 376 class documentViewer(Folder):
|
docinfo = {} |
docinfo = {} |
|
|
if dom is None: |
if dom is None: |
dom = self.getIndexMeta(getParentDir(path)) |
for x in range(cut+1): |
|
path=getParentDir(path) |
|
dom = self.getIndexMeta(path) |
|
|
# put in all raw bib fields as dict "bib" |
# put in all raw bib fields as dict "bib" |
bib = dom.xpath("//bib/*") |
bib = dom.xpath("//bib/*") |
Line 508 class documentViewer(Folder):
|
Line 524 class documentViewer(Folder):
|
pass |
pass |
return docinfo |
return docinfo |
|
|
def getDocinfoFromImagePath(self,path,docinfo=None): |
def getDocinfoFromImagePath(self,path,docinfo=None,cut=0): |
"""path ist the path to the images it assumes that the index.meta file is one level higher.""" |
"""path ist the path to the images it assumes that the index.meta file is one level higher.""" |
logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path)) |
logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path)) |
if docinfo is None: |
if docinfo is None: |
docinfo = {} |
docinfo = {} |
path=path.replace("/mpiwg/online","") |
path=path.replace("/mpiwg/online","") |
docinfo['imagePath'] = path |
docinfo['imagePath'] = path |
docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo) |
docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) |
imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
docinfo['imageURL'] = imageUrl |
docinfo['imageURL'] = imageUrl |
|
|
docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo) |
docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo) |
docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) |
return docinfo |
return docinfo |
|
|
|
|
Line 540 class documentViewer(Folder):
|
Line 556 class documentViewer(Folder):
|
docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) |
docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) |
elif mode=="imagepath": |
elif mode=="imagepath": |
docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) |
docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) |
|
elif mode=="filepath": |
|
docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) |
else: |
else: |
logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!") |
logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!") |
raise ValueError("Unknown mode %s"%(mode)) |
raise ValueError("Unknown mode %s"%(mode)) |
Line 570 class documentViewer(Folder):
|
Line 588 class documentViewer(Folder):
|
pageinfo['numgroups'] = int(np / grpsize) |
pageinfo['numgroups'] = int(np / grpsize) |
if np % grpsize > 0: |
if np % grpsize > 0: |
pageinfo['numgroups'] += 1 |
pageinfo['numgroups'] += 1 |
|
logging.debug("getPageInfo: %s"%repr(pageinfo)) |
return pageinfo |
return pageinfo |
|
|
def text(self,mode,url,pn): |
def text(self,mode,url,pn): |