--- documentViewer/documentViewer.py 2011/08/04 14:57:02 1.175.2.17 +++ documentViewer/documentViewer.py 2011/08/05 17:04:20 1.175.2.21 @@ -266,7 +266,7 @@ class documentViewer(Folder): security.declareProtected('View','index_html') - def index_html(self,url,mode="texttool",viewMode="auto",viewTYpe=None,tocMode="thumbs"): + def index_html(self,url,mode="texttool",viewMode="auto",viewType=None,tocMode="thumbs",start=1,pn=1): """ view page @param url: url which contains display information @@ -276,7 +276,7 @@ class documentViewer(Folder): @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) """ - logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) + logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewType=%s start=%s pn=%s"%(mode,url,viewMode,viewType,start,pn)) if not hasattr(self, 'template'): # this won't work @@ -300,10 +300,24 @@ class documentViewer(Folder): else: viewMode = "images" - pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viweType=viewType, tocMode=tocMode) + elif viewMode == "text_dict": + # legacy fix + viewMode = "text" + viewType = "dict" + + # stringify viewType + if isinstance(viewType, list): + viewType = ','.join([t for t in viewType if t]) + + pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewType=viewType, tocMode=tocMode) - # get template /template/viewer_main - pt = getattr(self.template, 'viewer_main') + # get template /template/viewer_$viewMode + pt = getattr(self.template, 'viewer_%s'%viewMode, None) + if pt is None: + logging.error("No template for viewMode=%s!"%viewMode) + # TODO: error page? + return "No template for viewMode=%s!"%viewMode + # and execute with parameters return pt(docinfo=docinfo, pageinfo=pageinfo) @@ -374,7 +388,7 @@ class documentViewer(Folder): """returns URL to documentviewer with parameter param set to val or from dict params""" urlParams = self.getParams(param=param, val=val, params=params) # quote values and assemble into query string (not escaping '/') - ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(v,'/')) for (k, v) in urlParams.items()]) + ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(unicode(v),'/')) for (k, v) in urlParams.items()]) if baseUrl is None: baseUrl = self.getDocumentViewerURL() @@ -461,7 +475,7 @@ class documentViewer(Folder): docinfo['documentUrl'] = docUrl # process index.meta contents - if metaDom is not None: + if metaDom is not None and metaDom.tag == 'resource': # document directory name and path resource = self.metadataService.getResourceData(dom=metaDom) if resource: