Mercurial > hg > documentViewer
diff documentViewer.py @ 543:6cdc31e9ed8e
fixed problem with dict-mode in default view.
added configurable footer and logo in site_template.pt
author | casties |
---|---|
date | Wed, 22 Aug 2012 16:25:38 +0200 |
parents | c4cc01b104d7 |
children | 2928037f9a75 |
line wrap: on
line diff
--- a/documentViewer.py Tue Aug 21 13:28:35 2012 +0200 +++ b/documentViewer.py Wed Aug 22 16:25:38 2012 +0200 @@ -260,11 +260,11 @@ security.declareProtected('View','index_html') def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode="thumbs",start=1,pn=1): """ - view page + show page @param url: url which contains display information @param mode: defines how to access the document behind url @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto' - @param viewLayer: sub-type of viewMode, e.g. 'dict' for viewMode='text' + @param viewLayer: sub-type of viewMode, e.g. layer 'dict' for viewMode='text' @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) """ @@ -278,14 +278,19 @@ if not getattr(self, 'digilibBaseUrl', None): self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" + # docinfo: information about document (cached) docinfo = self.getDocinfo(mode=mode,url=url,tocMode=tocMode) + # userinfo: user settings (cached) + userinfo = self.getUserinfo() + # auto viewMode: text if there is a text else images if viewMode=="auto": if docinfo.get('textURLPath', None): # docinfo.get('textURL', None) not implemented yet viewMode = "text" - if viewLayer is None: + if viewLayer is None and 'viewLayer' not in userinfo: + # use layer dict as default viewLayer = "dict" else: viewMode = "images" @@ -295,7 +300,11 @@ viewMode = "text" viewLayer = "dict" - pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode) + # safe viewLayer in userinfo + userinfo['viewLayer'] = viewLayer + + # pageinfo: information about page (not cached) + pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode) # get template /template/viewer_$viewMode pt = getattr(self.template, 'viewer_%s'%viewMode, None) @@ -494,6 +503,20 @@ return False + def getUserinfo(self): + """returns userinfo object""" + logging.debug("getUserinfo") + userinfo = {} + # look for cached userinfo in session + if self.REQUEST.SESSION.has_key('userinfo'): + userinfo = self.REQUEST.SESSION['userinfo'] + # check if its still current? + else: + # store in session + self.REQUEST.SESSION['userinfo'] = userinfo + + return userinfo + def getDocinfo(self, mode, url, tocMode=None): """returns docinfo depending on mode""" logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url)) @@ -771,7 +794,7 @@ return docinfo - def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None): + def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, userinfo=None, viewMode=None, viewLayer=None, tocMode=None): """returns pageinfo with the given parameters""" logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode)) pageinfo = {}