Changeset 167:7e2b97941a66 in documentViewer for documentViewer.py


Ignore:
Timestamp:
Aug 24, 2010, 12:43:24 PM (14 years ago)
Author:
abukhman
Branch:
default
Message:

characterNormalization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r166 r167  
    6969    for cnt in range(num_tries):
    7070        try:
    71             #logging.debug("getHttpData(#%s %ss) url=%s"%(cnt+1,timeout,url))
     71            logging.debug("getHttpData(#%s %ss) url=%s"%(cnt+1,timeout,url))
    7272            if sys.version_info < (2, 6):
    7373                # set timeout on socket -- ugly :-(
     
    8080            break
    8181        except urllib2.HTTPError, e:
    82             #logging.error("getHttpData: HTTP error(%s): %s"%(e.code,e))
     82            logging.error("getHttpData: HTTP error(%s): %s"%(e.code,e))
    8383            errmsg = str(e)
    8484            # stop trying
    8585            break
    8686        except urllib2.URLError, e:
    87             #logging.error("getHttpData: URLLIB error(%s): %s"%(e.reason,e))
     87            logging.error("getHttpData: URLLIB error(%s): %s"%(e.reason,e))
    8888            errmsg = str(e)
    8989            # stop trying
     
    204204       
    205205        '''
    206         #logging.debug("HHHHHHHHHHHHHH:load the rss")
    207         #logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
     206        logging.debug("HHHHHHHHHHHHHH:load the rss")
     207        logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
    208208       
    209209        if not hasattr(self, 'template'):
     
    238238        '''
    239239       
    240         #logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
     240        logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
    241241       
    242242        if not hasattr(self, 'template'):
     
    324324               
    325325        # quote values and assemble into query string
    326         #logging.debug("XYXXXXX: %s"%repr(params.items()))
     326        logging.debug("XYXXXXX: %s"%repr(params.items()))
    327327        ps = "&amp;".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
    328328        url=self.REQUEST['URL1']+"?"+ps
     
    343343        """returns if access to the resource is granted"""
    344344        access = docinfo.get('accessType', None)
    345         #logging.debug("documentViewer (accessOK) access type %s"%access)
     345        logging.debug("documentViewer (accessOK) access type %s"%access)
    346346        if access is not None and access == 'free':
    347             #logging.debug("documentViewer (accessOK) access is free")
     347            logging.debug("documentViewer (accessOK) access is free")
    348348            return True
    349349        elif access is None or access in self.authgroups:
    350350            # only local access -- only logged in users
    351351            user = getSecurityManager().getUser()
    352             #logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr()))
     352            logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr()))
    353353            if user is not None:
    354354                #print "user: ", user
     
    357357                return False
    358358       
    359         #logging.error("documentViewer (accessOK) unknown access type %s"%access)
     359        logging.error("documentViewer (accessOK) unknown access type %s"%access)
    360360        return False
    361361   
     
    372372        infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
    373373   
    374         #logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl))
     374        logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl))
    375375       
    376376        txt = getHttpData(infoUrl)
     
    380380        dom = Parse(txt)
    381381        sizes=dom.xpath("//dir/size")
    382         #logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)
     382        logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)
    383383       
    384384        if sizes:
     
    406406                metaUrl += "/index.meta"
    407407               
    408         #logging.debug("(getIndexMeta): METAURL: %s"%metaUrl)
     408        logging.debug("(getIndexMeta): METAURL: %s"%metaUrl)
    409409        txt=getHttpData(metaUrl)
    410410        if txt is None:
     
    436436    def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
    437437        """gets authorization info from the index.meta file at path or given by dom"""
    438         #logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path))
     438        logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path))
    439439       
    440440        access = None
     
    460460    def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
    461461        """gets bibliographical info from the index.meta file at path or given by dom"""
    462         #logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))
     462        logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))
    463463       
    464464        if docinfo is None:
     
    470470            dom = self.getIndexMeta(path)
    471471       
    472         #logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
     472        logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
    473473        # put in all raw bib fields as dict "bib"
    474474        bib = dom.xpath("//bib/*")
     
    501501                docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0])
    502502            except: pass
    503             #logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
     503            logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
    504504            try:
    505505                docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0])
     
    512512    def getDocinfoFromTextTool(self, url, dom=None, docinfo=None):
    513513        """parse texttool tag in index meta"""
    514         #logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url))
     514        logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url))
    515515        if docinfo is None:
    516516           docinfo = {}
     
    539539        else:
    540540            # try to get archive-path from url
    541             #logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url))
     541            logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url))
    542542            if (not url.startswith('http')):
    543543                archivePath = url.replace('index.meta', '')
     
    633633    def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):
    634634        """path ist the path to the images it assumes that the index.meta file is one level higher."""
    635         #logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path))
     635        logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path))
    636636        if docinfo is None:
    637637            docinfo = {}
     
    643643        for x in range(cut):       
    644644                path=getParentDir(path)
    645         #logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path)
     645        logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path)
    646646        imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path
    647647        docinfo['imageURL'] = imageUrl
     
    655655    def getDocinfo(self, mode, url):
    656656        """returns docinfo depending on mode"""
    657         #logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url))
     657        logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url))
    658658        # look for cached docinfo in session
    659659        if self.REQUEST.SESSION.has_key('docinfo'):
     
    661661            # check if its still current
    662662            if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:
    663                 #logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)
     663                logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)
    664664                return docinfo
    665665        # new docinfo
     
    672672            docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)
    673673        else:
    674             #logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)
     674            logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)
    675675            raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))
    676676                       
    677         #logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
     677        logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
    678678        self.REQUEST.SESSION['docinfo'] = docinfo
    679679        return docinfo
     
    702702        pageinfo['viewMode'] = viewMode
    703703        pageinfo['tocMode'] = tocMode
    704         pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','')
     704        pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ')
    705705        pageinfo['query'] = self.REQUEST.get('query',' ')
    706706        pageinfo['queryType'] = self.REQUEST.get('queryType',' ')
     
    768768    ob = getattr(self, id)
    769769    txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read()
    770     #logging.info("txt %s:"%txt)
     770    logging.info("txt %s:"%txt)
    771771    ob.pt_edit(txt,"text/html")
    772772    if title:
Note: See TracChangeset for help on using the changeset viewer.