Changeset 561:9255acc4518d in documentViewer
- Timestamp:
- Oct 1, 2012, 4:09:01 PM (12 years ago)
- Branch:
- default
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
MpdlXmlTextServer.py
r559 r561 33 33 manage_changeMpdlXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpdlXmlTextServer", globals()) 34 34 35 def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40 ):35 def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40, repositoryType='production'): 36 36 """constructor""" 37 37 self.id=id 38 38 self.title=title 39 39 self.timeout = timeout 40 self.repositoryType = repositoryType 40 41 if serverName is None: 41 42 self.serverUrl = serverUrl … … 52 53 return getHttpData(url,data,timeout=self.timeout) 53 54 55 56 def getRepositoryType(self): 57 """returns the repository type, e.g. 'production'""" 58 return self.repositoryType 54 59 55 60 def getTextDownloadUrl(self, type='xml', docinfo=None): … … 565 570 566 571 567 def manage_changeMpdlXmlTextServer(self,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40, RESPONSE=None):572 def manage_changeMpdlXmlTextServer(self,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,repositoryType=None,RESPONSE=None): 568 573 """change settings""" 569 574 self.title=title 570 575 self.timeout = timeout 571 576 self.serverUrl = serverUrl 577 if repositoryType: 578 self.repositoryType = repositoryType 572 579 if RESPONSE is not None: 573 580 RESPONSE.redirect('manage_main') -
documentViewer.py
r560 r561 33 33 # stream.close() 34 34 return s 35 36 def getMDText(node): 37 """returns the @text content from the MetaDataProvider metadata node""" 38 if isinstance(node, dict): 39 return node.get('@text', None) 40 41 return node 35 42 36 43 def browserCheck(self): … … 220 227 return self.template.fulltextclient.getTocPage(**args) 221 228 229 def getRepositoryType(self, **args): 230 """get repository type""" 231 return self.template.fulltextclient.getRepositoryType(**args) 232 222 233 def getTextDownloadUrl(self, **args): 223 234 """get list of gis places on one page""" … … 571 582 572 583 # texttool info 573 texttool = self.metadataService.getTexttoolData(dom=metaDom )584 texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True) 574 585 if texttool: 575 586 docinfo = self.getDocinfoFromTexttool(docinfo, texttool) … … 676 687 def getDocinfoFromTexttool(self, docinfo, texttool): 677 688 """reads contents of texttool element into docinfo""" 689 logging.debug("texttool=%s"%repr(texttool)) 690 # unpack list if necessary 691 if isinstance(texttool, list): 692 texttool = texttool[0] 693 678 694 # image dir 679 imageDir = texttool.get('image', None)680 docPath = docinfo.get('documentPath', None)695 imageDir = getMDText(texttool.get('image', None)) 696 docPath = getMDText(docinfo.get('documentPath', None)) 681 697 if imageDir and docPath: 682 698 #print "image: ", imageDir, " archivepath: ", archivePath … … 686 702 687 703 # old style text URL 688 textUrl = texttool.get('text', None)704 textUrl = getMDText(texttool.get('text', None)) 689 705 if textUrl and docPath: 690 706 if urlparse.urlparse(textUrl)[0] == "": #keine url … … 693 709 docinfo['textURL'] = textUrl 694 710 695 # new style text-url-path 696 textUrl = texttool.get('text-url-path', None) 697 if textUrl: 698 docinfo['textURLPath'] = textUrl 711 # new style text-url-path (can be more than one with "repository" attribute) 712 textUrlNode = texttool.get('text-url-path', None) 713 if not isinstance(textUrlNode, list): 714 textUrlNode = [textUrlNode] 715 716 for tun in textUrlNode: 717 textUrl = getMDText(tun) 718 if textUrl: 719 textUrlAtts = tun.get('@attr') 720 if (textUrlAtts and 'repository' in textUrlAtts): 721 textRepo = textUrlAtts['repository'] 722 # use matching repository 723 if self.getRepositoryType() == textRepo: 724 docinfo['textURLPath'] = textUrl 725 docinfo['textURLRepository'] = textRepo 726 727 else: 728 # no repo attribute - use always 729 docinfo['textURLPath'] = textUrl 699 730 700 731 # page flow 701 docinfo['pageFlow'] = texttool.get('page-flow', 'ltr')732 docinfo['pageFlow'] = getMDText(texttool.get('page-flow', 'ltr')) 702 733 703 734 # odd pages are left 704 docinfo['oddPage'] = texttool.get('odd-scan-position', 'left')735 docinfo['oddPage'] = getMDText(texttool.get('odd-scan-position', 'left')) 705 736 706 737 # number of title page (default 1) 707 docinfo['titlePage'] = texttool.get('title-scan-no', 1)738 docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', 1)) 708 739 709 740 # old presentation stuff 710 presentation = texttool.get('presentation', None)741 presentation = getMDText(texttool.get('presentation', None)) 711 742 if presentation and docPath: 712 743 if presentation.startswith('http:'): -
zpt/manage_changeMpdlXmlTextServer.zpt
r6 r561 12 12 <p class="form-optional">Timeout (s)</p> 13 13 <p class="form-element"><input size="3" tal:attributes="value here/timeout | default" name="timeout"></p> 14 <p class="form-optional">Repository type</p> 15 <p class="form-element"><input size="10" tal:attributes="value here/repositoryType | default" name="repositoryType"></p> 14 16 <p><input type="submit" value="change"></p> 15 17 </form>
Note: See TracChangeset
for help on using the changeset viewer.