Mercurial > hg > documentViewer
changeset 589:d8d6975cebcb
more fixes for pf-parameter
author | casties |
---|---|
date | Thu, 15 Nov 2012 17:58:14 +0100 |
parents | e1034c2ca255 |
children | ed4485d2748e |
files | documentViewer.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/documentViewer.py Thu Nov 15 17:20:03 2012 +0100 +++ b/documentViewer.py Thu Nov 15 17:58:14 2012 +0100 @@ -47,8 +47,8 @@ # split by /, shorten, and reassemble return '/'.join(path.split('/')[0:-cnt]) -def getPnForPf(docinfo, pf): - """returns image number for image file name or 0""" +def getPnForPf(docinfo, pf, default=0): + """returns image number for image file name or default""" if 'imgFileNames' in docinfo: pn = docinfo['imgFileNames'].get(pf, None) if pn is None: @@ -57,11 +57,14 @@ if xi > 0: pf = pf[:xi] # try again, else return 0 - pn = docinfo['imgFileNames'].get(pf, 0) + pn = docinfo['imgFileNames'].get(pf, default) + else: + # no extension + pn = default return pn - return 0 + return default ## @@ -234,7 +237,7 @@ security.declareProtected('View','index_html') - def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode=None,start=None,pn=None,pf=None): + def index_html(self, url, mode="texttool", viewMode="auto", viewLayer=None, tocMode=None, start=None, pn=None, pf=None): """ show page @param url: url which contains display information @@ -830,12 +833,13 @@ pageinfo['viewLayer'] = viewLayer pageinfo['tocMode'] = tocMode - # TODO: unify current and pn! - #pageinfo['current'] = current # pf takes precedence over pn if pf: pageinfo['pf'] = pf pn = getPnForPf(docinfo, pf) + # replace pf in request params (used for creating new URLs) + self.REQUEST.form.pop('pf', None) + self.REQUEST.form['pn'] = pn else: pn = getInt(pn, 1)