Changeset 561:9255acc4518d in documentViewer


Ignore:
Timestamp:
Oct 1, 2012, 4:09:01 PM (12 years ago)
Author:
casties
Branch:
default
Message:

CLOSED - # 256: display texts from different backends (sandbox)
https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/ticket/256

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • MpdlXmlTextServer.py

    r559 r561  
    3333    manage_changeMpdlXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpdlXmlTextServer", globals())
    3434       
    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'):
    3636        """constructor"""
    3737        self.id=id
    3838        self.title=title
    3939        self.timeout = timeout
     40        self.repositoryType = repositoryType
    4041        if serverName is None:
    4142            self.serverUrl = serverUrl
     
    5253        return getHttpData(url,data,timeout=self.timeout)
    5354
     55
     56    def getRepositoryType(self):
     57        """returns the repository type, e.g. 'production'"""
     58        return self.repositoryType
    5459
    5560    def getTextDownloadUrl(self, type='xml', docinfo=None):
     
    565570           
    566571   
    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):
    568573        """change settings"""
    569574        self.title=title
    570575        self.timeout = timeout
    571576        self.serverUrl = serverUrl
     577        if repositoryType:
     578            self.repositoryType = repositoryType
    572579        if RESPONSE is not None:
    573580            RESPONSE.redirect('manage_main')
  • documentViewer.py

    r560 r561  
    3333    #    stream.close()
    3434    return s
     35
     36def 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
    3542
    3643def browserCheck(self):
     
    220227        return self.template.fulltextclient.getTocPage(**args)
    221228
     229    def getRepositoryType(self, **args):
     230        """get repository type"""
     231        return self.template.fulltextclient.getRepositoryType(**args)
     232
    222233    def getTextDownloadUrl(self, **args):
    223234        """get list of gis places on one page"""
     
    571582
    572583            # texttool info
    573             texttool = self.metadataService.getTexttoolData(dom=metaDom)
     584            texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True)
    574585            if texttool:
    575586                docinfo = self.getDocinfoFromTexttool(docinfo, texttool)
     
    676687    def getDocinfoFromTexttool(self, docinfo, texttool):
    677688        """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                                   
    678694        # 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))
    681697        if imageDir and docPath:
    682698            #print "image: ", imageDir, " archivepath: ", archivePath
     
    686702       
    687703        # old style text URL
    688         textUrl = texttool.get('text', None)
     704        textUrl = getMDText(texttool.get('text', None))
    689705        if textUrl and docPath:
    690706            if urlparse.urlparse(textUrl)[0] == "": #keine url
     
    693709            docinfo['textURL'] = textUrl
    694710   
    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
    699730           
    700731        # page flow
    701         docinfo['pageFlow'] = texttool.get('page-flow', 'ltr')
     732        docinfo['pageFlow'] = getMDText(texttool.get('page-flow', 'ltr'))
    702733           
    703734        # odd pages are left
    704         docinfo['oddPage'] = texttool.get('odd-scan-position', 'left')
     735        docinfo['oddPage'] = getMDText(texttool.get('odd-scan-position', 'left'))
    705736           
    706737        # 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))
    708739           
    709740        # old presentation stuff
    710         presentation = texttool.get('presentation', None)
     741        presentation = getMDText(texttool.get('presentation', None))
    711742        if presentation and docPath:
    712743            if presentation.startswith('http:'):
  • zpt/manage_changeMpdlXmlTextServer.zpt

    r6 r561  
    1212        <p class="form-optional">Timeout (s)</p>
    1313        <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>
    1416                <p><input type="submit" value="change"></p>
    1517                </form>
Note: See TracChangeset for help on using the changeset viewer.