--- documentViewer/documentViewer.py 2007/06/29 15:44:40 1.31 +++ documentViewer/documentViewer.py 2008/11/04 19:51:35 1.33 @@ -83,6 +83,7 @@ class documentViewer(Folder): docuviewer_css = PageTemplateFile('css/docuviewer.css', globals()) info_xml = PageTemplateFile('zpt/info_xml', globals()) + thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) security.declareProtected('View management screens','changeDocumentViewerForm') changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals()) @@ -106,6 +107,37 @@ class documentViewer(Folder): self.manage_addFolder('template') + security.declareProtected('View','thumbs_rss') + def thumbs_rss(self,mode,url,viewMode="auto",start=None,pn=1): + ''' + view it + @param mode: defines how to access the document behind url + @param url: url which contains display information + @param viewMode: if images display images, if text display text, default is images (text,images or auto) + + ''' + logging.info("HHHHHHHHHHHHHH:load the rss") + logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) + + if not hasattr(self, 'template'): + # create template folder if it doesn't exist + self.manage_addFolder('template') + + if not self.digilibBaseUrl: + self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" + + docinfo = self.getDocinfo(mode=mode,url=url) + pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) + pt = getattr(self.template, 'thumbs_main_rss') + + if viewMode=="auto": # automodus gewaehlt + if docinfo.get("textURL",'') and self.textViewerUrl: #texturl gesetzt und textViewer konfiguriert + viewMode="text" + else: + viewMode="images" + + return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) + security.declareProtected('View','index_html') def index_html(self,mode,url,viewMode="auto",start=None,pn=1): ''' @@ -153,7 +185,21 @@ class documentViewer(Folder): url=self.REQUEST['URL1']+"?"+ps return url - + def getLinkAmp(self,param=None,val=None): + """link to documentviewer with parameter param set to val""" + params=self.REQUEST.form.copy() + if param is not None: + if val is None: + if params.has_key(param): + del params[param] + else: + params[param] = str(val) + + # quote values and assemble into query string + logging.info("XYXXXXX: %s"%repr(params.items())) + ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) + url=self.REQUEST['URL1']+"?"+ps + return url def getInfo_xml(self,url,mode): """returns info about the document as XML""" @@ -286,7 +332,7 @@ class documentViewer(Folder): 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""" logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path)) @@ -296,7 +342,9 @@ class documentViewer(Folder): docinfo = {} 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") if acctype and (len(acctype)>0): @@ -308,7 +356,7 @@ class documentViewer(Folder): 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""" logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) @@ -316,7 +364,9 @@ class documentViewer(Folder): docinfo = {} 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" bib = dom.xpath("//bib/*") @@ -462,7 +512,7 @@ class documentViewer(Folder): pass 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.""" logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path)) if docinfo is None: @@ -473,8 +523,8 @@ class documentViewer(Folder): imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path docinfo['imageURL'] = imageUrl - docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo) - docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo) + docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) + docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) return docinfo @@ -494,6 +544,8 @@ class documentViewer(Folder): docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) elif mode=="imagepath": docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) + elif mode=="filepath": + docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) else: logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!") raise ValueError("Unknown mode %s"%(mode))